// GL Shading Language version 1.0 Fragment Shader // Orion Sky Lawlor, olawlor@acm.org, 2005/2/10 (Public Domain) // Vertex/fragment shader interface varying vec4 world; // World position varying vec4 worldN; // World normal varying vec4 albedo; // Material diffuse color varying vec4 viewdir; // Viewer direction (to camera) uniform sampler3D myNoise; void main(void) { vec4 N=worldN; N=normalize(N); vec4 c=texture3D(myNoise,vec3(world)); // Diffuse term: usual lambertian+ambient float diffuse=(0.2+0.6*clamp(dot(N, gl_LightSource[0].position),0.0,1.0)); vec4 specular=vec4(pow(dot(gl_LightSource[0].position,reflect(-viewdir,N)),100.0)); float diffuseScale[3]; diffuseScale[0]=0.1; diffuseScale[1]=0.01; diffuseScale[2]=0.21; for (int i=0;i<3;i++) { diffuse+=diffuseScale[i]; } gl_FragColor=diffuse*c+specular; }