reflection geometry finally correct
[laserbrain_demo] / sdr / lightmap.p.glsl
1 /* vi: set ft=glsl */
2 #ifdef USE_TEXMAP
3 uniform sampler2D texmap;
4 #endif
5 uniform sampler2D lightmap;
6 #ifdef USE_MIRROR
7 uniform sampler2D mirrortex;
8 uniform vec2 mirtex_scale;
9 uniform float reflectivity;
10 #endif
11
12 void main()
13 {
14         vec3 lumel = texture2D(lightmap, gl_TexCoord[1].st).rgb;
15
16 #ifdef USE_TEXMAP
17         vec3 texel = texture2D(texmap, gl_TexCoord[0].st).rgb;
18         vec3 ambient = gl_LightModel.ambient.rgb * texel;
19         vec3 diffuse = lumel * texel * 1.8;
20 #else
21         vec3 ambient = gl_LightModel.ambient.rgb * gl_FrontMaterial.diffuse.rgb;
22         vec3 diffuse = gl_FrontMaterial.diffuse.rgb * lumel * 1.8;
23 #endif
24
25 #ifdef USE_MIRROR
26         vec3 refl = texture2D(mirrortex, gl_FragCoord.xy * mirtex_scale).rgb;
27         diffuse += refl * reflectivity; // just add it to diffuse until we get another source of specularity
28 #endif
29
30         gl_FragColor.rgb = ambient + diffuse;
31         gl_FragColor.a = gl_FrontMaterial.diffuse.a;
32 }