-
Notifications
You must be signed in to change notification settings - Fork 1
/
Hello_World.frag
39 lines (30 loc) · 913 Bytes
/
Hello_World.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
38
39
// Author: Jeremy Rotsztain
// Workshop: Generating Images with Shaders @ InterAccess, 2020
// Title: Hello World (GLSL)
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
void main() {
// get the xy coordinate in pixels & normalize to [0, 1] range
// by dividing by width (500 x 500 px)
vec2 st = gl_FragCoord.xy/u_resolution.xy;
// fix for aspect ratio
st.x *= u_resolution.x/u_resolution.y;
// set a fill color with r,g,b,a
// store as vec4 (normalized)
// hover for color picker
vec4 color = vec4(1., 0., 0., 1.);
// set individual rgb components
// hover over float to access slider
//color.r = 0.0;
//color.g = 1.0;
//color.b = 0.5;
// create a gradient
//color.r = st.x;
//color.g = st.y;
//color.b = 1.0-st.x;
gl_FragColor = color;
}