-
Notifications
You must be signed in to change notification settings - Fork 6
/
03_SquareStep.fs
executable file
·68 lines (61 loc) · 1.15 KB
/
03_SquareStep.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// #SaturdayShader Week 3 : SquareStep
// 2015-09-05
// Based on the "Step" example by Patricio Gonzalez Vivo on http://patriciogonzalezvivo.com/2015/thebookofshaders/05/
/*{
"CREDIT": "Joseph Fiola",
"DESCRIPTION": "",
"CATEGORIES": [
"Generator", "Geometry"
],
"INPUTS": [
{
"NAME": "left",
"TYPE": "float",
"DEFAULT": 0.1,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "right",
"TYPE": "float",
"DEFAULT": 0.9,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "top",
"TYPE": "float",
"DEFAULT": 0.1,
"MIN": 0.0,
"MAX": 1.0
},
{
"NAME": "bottom",
"TYPE": "float",
"DEFAULT": 0.9,
"MIN": 0.0,
"MAX": 1.0
}
]
}
*/
#ifdef GL_ES
precision mediump float;
#endif
void main() {
vec2 st = gl_FragCoord.xy/RENDERSIZE;
float y;
if(right > left){
y = step(st.x,right) * step(left, st.x);
} else if(right < left){
y = step(st.x,left) * step(right, st.x);
}
float x;
if(top>bottom){
x = step(st.y, top) * step(bottom, st.y);
} else if(top < bottom){
x = step(st.y, bottom) * step(top, st.y);
}
vec3 color = vec3(y * x);
gl_FragColor = vec4(color,1.0);
}