Skip to content

Instantly share code, notes, and snippets.

@redaphid
Last active February 3, 2024 22:13
Show Gist options
  • Save redaphid/c79427e84badffc922cfe1eb6a21981f to your computer and use it in GitHub Desktop.
Save redaphid/c79427e84badffc922cfe1eb6a21981f to your computer and use it in GitHub Desktop.
Demo of shaders that can run anywhere
void mainImage(out vec4 color,in vec2 fragCoord){
vec2 resolution=iResolution.xy;
// Adjusted coordinates to center the circle
vec2 uv=(vec2(fragCoord.x,resolution.y-fragCoord.y)/resolution.xy-.5)*2.;
float radius=iMouse.x/1000.;
#ifdef PAPER_CRANES
radius = energyNormalized;
#endif
// Calculate the distance from the center
float dist=length(uv);
// Determine if we're inside the circle
if(dist<radius){
// Inside the circle
color=vec4(0.,0.,1.,1.);
return;
}
color=vec4(0.,0.,0.,0.);// Transparent
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment