Skip to content

Instantly share code, notes, and snippets.

@randompast
Created December 28, 2020 12:55
Show Gist options
  • Save randompast/4f2384a7c6e0873c8f298514ad4b6d64 to your computer and use it in GitHub Desktop.
Save randompast/4f2384a7c6e0873c8f298514ad4b6d64 to your computer and use it in GitHub Desktop.
a simple squiggle shader
//http://glslsandbox.com/e#70157.0
//squiggle
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_OES_standard_derivatives : enable
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
float distanceFunction(vec2 pos) {
//(angle)
float a = atan(pos.x/pos.y);
// frequency
float f = 10.;
float modf = ceil(1.+cos(time*f));
float squiggle = sin( f * a * modf) * 0.05*cos(time*f);
return length(pos) - 0.5 - squiggle;
}
void main( void ) {
vec2 p = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);
vec3 col = vec3(1.0) * distanceFunction(p);
col = smoothstep(0.1, 0.11, col);
gl_FragColor = vec4(col, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment