Skip to content

Instantly share code, notes, and snippets.

@ivcn
Created April 8, 2017 11:10
Show Gist options
  • Select an option

  • Save ivcn/e17b9cbf758fa587b91ba0c748b5bad8 to your computer and use it in GitHub Desktop.

Select an option

Save ivcn/e17b9cbf758fa587b91ba0c748b5bad8 to your computer and use it in GitHub Desktop.
simple 2D shader
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 center = iResolution.xy / 2.0;
float r1 = iResolution.y / 5.0;
float r2 = iResolution.y / 3.0;
vec2 uv = fragCoord.xy / iResolution.xy;
float dist = distance(fragCoord.xy, center);
if( dist >= r1 && dist <= r2) {
float d = (dist-r1)/(r2-r1);
fragColor = vec4(d, 1.0-d, 0.5+0.5*sin(iGlobalTime), 1);
}
else
fragColor = vec4(uv,0.5+0.5*cos(iGlobalTime),1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment