Skip to content

Instantly share code, notes, and snippets.

@grazer
Last active March 8, 2023 23:41
Show Gist options
  • Save grazer/6774782 to your computer and use it in GitHub Desktop.
Save grazer/6774782 to your computer and use it in GitHub Desktop.
red circle GLSL fragment shader
void main(void) {
// the center of the texture
vec2 center = vec2(iResolution.x/2.0,iResolution.y/2.0);
// current pixel location
vec2 loc = gl_FragCoord.xy;
// how far we are from the center
float radius=length(loc-center);
// if we are within our circle, paint it red
if (radius<100.0)
gl_FragColor = vec4(1,0,0,1); // red
else
gl_FragColor = vec4(0,0,0,1); // black
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment