Skip to content

Instantly share code, notes, and snippets.

@psql
Created June 20, 2018 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psql/b980dad66b6725e5f4c04cd0976c6bc5 to your computer and use it in GitHub Desktop.
Save psql/b980dad66b6725e5f4c04cd0976c6bc5 to your computer and use it in GitHub Desktop.
range map.glsl
#ifdef GL_ES
precision mediump float;
#endif
#define PI 3.14159265359
float plot(vec2 st, float pct){
return smoothstep( pct-0.01, pct, st.y) -
smoothstep( pct, pct+1.0, st.x);
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution;
float y = st.x * cos(st.x / u_time) * sin(u_time*st.x);
vec3 color = vec3(y);
// Plot a line
float pct = plot(st,y);
color = (1.0/pct)*color+pct*vec3(0.479, 0.294, 0.738);
gl_FragColor = vec4(color,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment