Skip to content

Instantly share code, notes, and snippets.

@csaez
Last active April 17, 2017 16:49
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 csaez/f41f3c66f16f5c5f451879566a1fd6d4 to your computer and use it in GitHub Desktop.
Save csaez/f41f3c66f16f5c5f451879566a1fd6d4 to your computer and use it in GitHub Desktop.
Stupid smiley face shadertoy shader
float circle(vec2 uv, vec2 p, float r, float blur)
{
return smoothstep( r, r-blur, length(uv - p) );
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = ( fragCoord.xy / iResolution.xy ) - .5f;
vec2 pos = ( iMouse.xy / iResolution.xy ) - .5f;
float ratio = iResolution.x/iResolution.y;
uv.x *= ratio;
pos.x *= ratio;
float mask = circle(uv, pos, .4f, .01f);
mask -= circle(uv, pos + vec2(.15f, .1f), .09f, .01f);
mask -= circle(uv, pos + vec2(-.15f, .1f), .09f, .01f);
float mouth = circle(uv, pos, .3f, .01f);
mouth -= circle(uv, pos + vec2(0.f, 0.1f), .3f, .01f);
mouth = clamp(mouth, 0.f, 1.f);
mask -= mouth;
const vec3 color = vec3(1.f, 1.f, 0.f);
fragColor = vec4(mask * color, 1.0f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment