-
Notifications
You must be signed in to change notification settings - Fork 1
/
Shaping_I_(Square).frag
37 lines (28 loc) · 990 Bytes
/
Shaping_I_(Square).frag
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
// Author: Jeremy Rotsztain
// Workshop: Generating Images with Shaders @ InterAccess, 2020
// Title: Shaping I: Square
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
void main() {
// get the xy coordinates & normalize to [0, 1] range
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
// setup an rgb fill color
vec3 color = vec3(0.);
// square fills 60% of canvas (20% border on each side)
// use step to show pixels that are greater than 0.2
color.r = step(0.2, st.x);
// use step to show pixels that are less than 0.8
// note 1.0-vale to invert results
//color.g = 1.0-step(0.8, st.x);
//color.r *= 1.0-step(0.8, st.x);
// make a red square (for malevich)
// note: disable green channel first!
//color.r *= step( 0.2, st.y);
//color.r *= 1.0-step( 0.8, st.y);
gl_FragColor = vec4(color, 1.0);
}