mirror of
https://github.com/patriciogonzalezvivo/thebookofshaders
synced 2024-11-01 21:40:27 +00:00
37 lines
875 B
GLSL
37 lines
875 B
GLSL
|
#ifdef GL_ES
|
||
|
precision mediump float;
|
||
|
#endif
|
||
|
|
||
|
#define PI 3.14159265359
|
||
|
|
||
|
uniform vec2 u_resolution;
|
||
|
uniform vec2 u_mouse;
|
||
|
uniform float u_time;
|
||
|
|
||
|
vec3 colorA = vec3(0.149,0.141,0.912);
|
||
|
vec3 colorB = vec3(1.000,0.833,0.224);
|
||
|
|
||
|
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);
|
||
|
// pct.g = sin(st.x*PI);
|
||
|
// pct.b = pow(st.x,0.5);
|
||
|
|
||
|
color = mix(colorA, colorB, pct);
|
||
|
|
||
|
// Plot transition lines for each channel
|
||
|
color = mix(color,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);
|
||
|
}
|