-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.frag
More file actions
26 lines (17 loc) · 837 Bytes
/
Copy pathbasic.frag
File metadata and controls
26 lines (17 loc) · 837 Bytes
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
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution; // This is passed in as a uniform from the sketch.js file
void main() {
// position of the pixel divided by resolution, to get normalized positions on the canvas
vec2 st = gl_FragCoord.xy/u_resolution.xy;
// Lets use the pixels position on the x-axis as our gradient for the red color
// Where the position is closer to 0.0 we get black (st.x = 0.0)
// Where the position is closer to width (defined as 1.0) we get red (st.x = 1.0)
gl_FragColor = vec4(st.x,0.0,0.0,1.0); // R,G,B,A
// you can only have one gl_FragColor active at a time, but try commenting the others out
// try the green component
//gl_FragColor = vec4(0.0,st.x,0.0,1.0);
// try both the x position and the y position
//gl_FragColor = vec4(st.x,st.y,0.0,1.0);
}