1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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);
}
|