/******************************************************************************* * * Simple GLSL FX file * *******************************************************************************/ #pragma language GLSL // un-tweakables // structures and shaders ///////////////////// varying vec3 eyeNormal; void mainVS() { // Must write gl_Position for rasterization to be defined.... // gl_Position = ftransform(); // Transform to shading space (we are going to shade in eyespace) // eyeNormal = gl_NormalMatrix * gl_Normal; } // fragment settings uniform vec3 diffuse = vec3(1.0,1.0,0.0); uniform float shininess = 16; uniform float steps = 6; const vec3 white = vec3(1.0); void mainPS() { vec3 normal; vec4 MyColor; vec4 tex; vec3 color; float turb; float illum; float s0,t0; vec3 lightDirection=vec3(1.0,1.0,1.0); lightDirection = normalize(lightDirection); vec4 Intensity; // // Since the EyeNormal is getting interpolated, we // have to first restore it by normalizing it. // normal = normalize( eyeNormal ); //compute a half vector, assuming infinite viewer vec3 hlf = normalize( lightDirection + vec3(0.0,0.0,1.0)); //compute the diffuse illumination illum = clamp( dot(normal, lightDirection), 0.0, 1.0); //add diffuse color and specular color = clamp( diffuse*(illum+0.2) + pow( max(dot(hlf,normal),0.0), 16.0), 0.0, 1.0); //apply a step function color = floor(color*steps) /steps; gl_FragColor = vec4( color, 1.0); } //////// techniques //////////////////////////// technique Toon0 { pass p0 { VertexShader = compile vs_2_0 mainVS(); ZEnable = true; ZWriteEnable = true; ZFunc = Less; CullMode = None; //FillMode = Point; //PointSize = 32.0; //DepthBias = 200.0; PixelShader = compile ps_2_0 mainPS(); } }