initial: added basic stuff
This commit is contained in:
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# GLSL playground
|
||||
|
||||
A few sketches I made while working throught [The Book of Shaders](https://thebookofshaders.com/).
|
9
basic/colorchange.glsl
Normal file
9
basic/colorchange.glsl
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(abs(sin(u_time)),0.5,abs(tan(u_time*0.5)),1.0);
|
||||
}
|
12
basic/colorchange_mouse.glsl
Normal file
12
basic/colorchange_mouse.glsl
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform vec2 u_mouse;
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
vec2 st = (gl_FragCoord.xy+u_mouse)/(u_resolution*vec2(2, 2));
|
||||
gl_FragColor = vec4(st.x, st.y, abs(sin(u_time)*0.8), 1.0);
|
||||
}
|
31
basic/dancing_funs.glsl
Normal file
31
basic/dancing_funs.glsl
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
#define PI 3.14159265359
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
|
||||
float plot (vec2 st, float pct){
|
||||
return smoothstep( pct-0.01, pct, st.y) -
|
||||
smoothstep( pct, pct+0.01, st.y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
vec3 pct = vec3(st.x);
|
||||
|
||||
pct.r = smoothstep(0.0,1.0, st.x*abs(sin(u_time)));
|
||||
pct.g = sin(st.x*PI*u_time);
|
||||
pct.b = pow(st.x*abs(cos(u_time)),0.5);
|
||||
|
||||
// Plot transition lines for each channel
|
||||
color = mix(vec3(0.0),vec3(1.0,0.0,0.0),plot(st,pct.r));
|
||||
color = mix(color,vec3(0.0,1.0,0.0),plot(st,pct.g));
|
||||
color = mix(color,vec3(0.0,0.0,1.0),plot(st,pct.b));
|
||||
|
||||
gl_FragColor = vec4(color,1.0);
|
||||
}
|
22
basic/dancing_sine.glsl
Normal file
22
basic/dancing_sine.glsl
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
|
||||
float plot(vec2 st, float pct){
|
||||
return smoothstep( pct-0.02, pct, st.y) -
|
||||
smoothstep( pct, pct+0.02, st.y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 st = gl_FragCoord.xy/u_resolution;
|
||||
|
||||
float y = sin(st.x*u_time);
|
||||
|
||||
float pct = plot(st,y);
|
||||
vec3 color = pct*vec3(0.0,1.0,0.0);
|
||||
|
||||
gl_FragColor = vec4(color,1.0);
|
||||
}
|
21
basic/sunset.glsl
Normal file
21
basic/sunset.glsl
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
uniform float u_time;
|
||||
|
||||
void main() {
|
||||
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
||||
vec3 sun = vec3(1.0*abs(sin(u_time)), .0, 0.4*abs(cos(u_time)));
|
||||
|
||||
vec3 pct = vec3(st.x);
|
||||
|
||||
vec3 color = sun;
|
||||
color *= vec3(step(0.4, st.y));
|
||||
if (step(0.4, st.y)<1.0) {
|
||||
color = sun * vec3(smoothstep(0.2, 0.4, st.y));
|
||||
color += vec3(0.3,0.2,0.9);
|
||||
}
|
||||
gl_FragColor = vec4(color,1.0);
|
||||
}
|
Reference in New Issue
Block a user