summaryrefslogtreecommitdiffstats
path: root/headtrack_stereo_demo/shadertest/testshaders/greyscale.frag
diff options
context:
space:
mode:
Diffstat (limited to 'headtrack_stereo_demo/shadertest/testshaders/greyscale.frag')
-rw-r--r--headtrack_stereo_demo/shadertest/testshaders/greyscale.frag51
1 files changed, 51 insertions, 0 deletions
diff --git a/headtrack_stereo_demo/shadertest/testshaders/greyscale.frag b/headtrack_stereo_demo/shadertest/testshaders/greyscale.frag
new file mode 100644
index 0000000..5ef9084
--- /dev/null
+++ b/headtrack_stereo_demo/shadertest/testshaders/greyscale.frag
@@ -0,0 +1,51 @@
+//uniform vec3 g_ConversionWeights;
+
+
+varying vec4 ambient, diffuse;
+varying vec3 normal, lightdir, halfvector;
+
+//uniform sampler2D tex, hello;
+
+void main()
+{
+ float NdotL, NdotHV, gray;
+ vec3 n = normalize(normal);
+ vec4 // texcolor = texture2D(tex, gl_TexCoord[0].st),
+ fragcolor = ambient,
+ color;
+
+ //compute the dot pruduct of the normalized normal and light direction
+ NdotL = max(dot(n, lightdir), 0.0);
+
+ if (NdotL > 0.0)
+ {
+ //add diffuse light component
+ fragcolor += diffuse * NdotL;
+
+ //compute the dot product of the normal and half vector (of the lightdir and eye position)
+ NdotHV = max(dot(n, halfvector), 0.0);
+
+ fragcolor += gl_FrontMaterial.specular * gl_LightSource[0].specular *
+ pow(NdotHV, gl_FrontMaterial.shininess);
+ }
+
+
+
+ //modulate the fragment color with the texel color for the final color
+// color = texcolor * fragcolor;
+ color = fragcolor;
+
+ //smoothstep not available on ati motbility 8600
+ //color += smoothstep(1.0,0.2,NdotL) * texture2D(hello, gl_TexCoord[0].st);
+
+ //convert to grayscale using NTSC conversion weights
+ gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
+ //gray = dot(color.rgb, g_ConversionWeights);
+ //gray = color.r * 0.299 + color.g * 0.587 + color.b * 0.114;
+
+ //copy grayscale to rgb components and use the alpha from the final color
+ gl_FragColor = vec4(gray, gray, gray, color.a);
+
+ // convert grayscale to sepia
+ //gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), color.a);
+} \ No newline at end of file