Skip to content

Instantly share code, notes, and snippets.

@0b5vr
Created December 5, 2014 08:58
Show Gist options
  • Save 0b5vr/cecd83f944c8cb665a9b to your computer and use it in GitHub Desktop.
Save 0b5vr/cecd83f944c8cb665a9b to your computer and use it in GitHub Desktop.
20141205
#define PI 3.1415926
void main(void)
{
vec2 uv=vec2(gl_FragCoord.xy-iResolution.xy/2.0);
vec2 mouse=vec2(iMouse.xy-iResolution.xy/2.0);
if(length(uv)<100.0)
{
vec3 nor=vec3(0.0);
nor.z=cos(length(uv)/100.*PI/2.);
nor.xy=normalize(uv);
nor.xy*=abs(sin(length(uv)/100.*PI/2.));
vec3 lig=vec3(mouse*.01,-1.0);
vec3 cam=vec3(0.0,0.0,-1.0);
float dif=clamp(dot(-nor,lig)*.5,0.0,1.0)*.6;
float amb=.6;
float spe=clamp(pow(dot(-nor,normalize(lig+cam)),15.0),0.0,1.0)*.2;
gl_FragColor=vec4(vec3(0.9,0.7,0.6)*(dif+amb)+vec3(1.0)*spe,1.0);
}
else
{
gl_FragColor=vec4(0.0,0.0,0.0,1.0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment