OpenGL Shading Language - Live Shader
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 resolution;
uniform vec2 mouse;
uniform vec3 spectrum;
uniform float time;
// Plot a line on Y using a value between 0.0-1.0
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/resolution;
float y = st.x;
vec3 color = vec3(0,0,0);
vec3 spec = spectrum*27.0;
// Plot a line
float pct = plot(st,spec.x);
color = (1.0-pct)*color+pct*vec3(0,1,1);
gl_FragColor = vec4(color,1.0);
}
------- Parabola
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
uniform vec2 resolution;
uniform vec2 mouse;
uniform vec3 spectrum;
uniform float time;
// Plot a line on Y using a value between 0.0-1.0
float plot(vec2 st, float pct){
return smoothstep( pct-0.01, pct, st.y) -
smoothstep( pct, pct+0.01, st.y);
}
float impulse( float k, float x )
{
float h = k*x;
return h*exp(1.0-h);
}
float parabola( float x, float k )
{
return pow( 4.0*x*(1.0-x), k );
}
void main() {
vec2 st = gl_FragCoord.xy/resolution;
float y=parabola(st.x,2.0);
vec3 color = vec3(0,0,0);
vec3 spec = .1+spectrum;
// Plot a line
float pct = plot(st*spec.x,y*spec.y);
color = (1.0-pct)*color+pct*vec3(0.3,0.3,0.3);
gl_FragColor = vec4(color,1.0);
}