Debian Codegraph @

Shaders/text.frag

raw
1 #version 120
2
3 uniform sampler2D glyphTexture;
4
5 varying vec4 diffuse_term;
6 varying vec3 normal;
7 varying vec4 ecPosition;
8
9 ////fog "include" /////
10 vec3 fog_Func(vec3 color, int type);
11 //////////////////////
12
13 float getShadowing();
14 vec3 getClusteredLightsContribution(vec3 p, vec3 n, vec3 texel);
15
16 void main()
17 {
18 float alpha = texture2D(glyphTexture, gl_TexCoord[0].st).a;
19 if (alpha == 0.0) discard;
20
21 float NdotL, NdotHV, fogFactor;
22 vec4 color = gl_Color;
23 vec3 lightDir = gl_LightSource[0].position.xyz;
24 vec3 halfVector = gl_LightSource[0].halfVector.xyz;
25 vec3 n = normalize(normal);
26 vec4 fragColor;
27 vec4 specular = vec4(0.0);
28
29 NdotL = dot(n, lightDir);
30 if (NdotL > 0.0) {
31 float shadowmap = getShadowing();
32 color += diffuse_term * NdotL * shadowmap;
33 NdotHV = max(dot(n, halfVector), 0.0);
34 if (gl_FrontMaterial.shininess > 0.0)
35 specular.rgb = (gl_FrontMaterial.specular.rgb
36 * gl_LightSource[0].specular.rgb
37 * pow(NdotHV, gl_FrontMaterial.shininess)
38 * shadowmap);
39 }
40 // This shouldn't be necessary, but our lighting becomes very
41 // saturated. Clamping the color before modulating by the texture
42 // is closer to what the OpenGL fixed function pipeline does.
43 color = clamp(color, 0.0, 1.0);
44
45 fragColor = color + specular;
46 fragColor = vec4(fragColor.rgb, fragColor.a * alpha);
47 fragColor.rgb += getClusteredLightsContribution(ecPosition.xyz, n, gl_Color.rgb);
48
49 fragColor.rgb = fog_Func(fragColor.rgb, 0);
50 gl_FragColor = fragColor;
51 }