fixed reflections in VR
[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_offs;
9 uniform vec2 mirtex_scale;
10 uniform float reflectivity;
11 #endif
12
13 void main()
14 {
15         vec3 lumel = texture2D(lightmap, gl_TexCoord[1].st).rgb;
16
17 #ifdef USE_TEXMAP
18         vec3 texel = texture2D(texmap, gl_TexCoord[0].st).rgb;
19         vec3 ambient = gl_LightModel.ambient.rgb * texel;
20         vec3 diffuse = lumel * texel * 1.8;
21 #else
22         vec3 ambient = gl_LightModel.ambient.rgb * gl_FrontMaterial.diffuse.rgb;
23         vec3 diffuse = gl_FrontMaterial.diffuse.rgb * lumel * 1.8;
24 #endif
25
26 #ifdef USE_MIRROR
27         vec3 refl = texture2D(mirrortex, (gl_FragCoord.xy + mirtex_offs) * mirtex_scale).rgb;
28         diffuse += refl * reflectivity; // just add it to diffuse until we get another source of specularity
29 #endif
30
31         gl_FragColor.rgb = ambient + diffuse;
32         gl_FragColor.a = gl_FrontMaterial.diffuse.a;
33 }