forgot to add the new shader
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 18 Mar 2018 12:47:08 +0000 (14:47 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 18 Mar 2018 12:47:08 +0000 (14:47 +0200)
sdr/lightmap.p.glsl [new file with mode: 0644]

diff --git a/sdr/lightmap.p.glsl b/sdr/lightmap.p.glsl
new file mode 100644 (file)
index 0000000..37b2abb
--- /dev/null
@@ -0,0 +1,32 @@
+/* vi: set ft=glsl */
+#ifdef USE_TEXMAP
+uniform sampler2D texmap;
+#endif
+uniform sampler2D lightmap;
+#ifdef USE_MIRROR
+uniform sampler2D mirrortex;
+uniform vec2 mirtex_scale;
+uniform float reflectivity;
+#endif
+
+void main()
+{
+       vec3 lumel = texture2D(lightmap, gl_TexCoord[1].st).rgb;
+
+#ifdef USE_TEXMAP
+       vec3 texel = texture2D(texmap, gl_TexCoord[0].st).rgb;
+       vec3 ambient = gl_LightModel.ambient.rgb * texel;
+       vec3 diffuse = lumel * texel * 1.8;
+#else
+       vec3 ambient = gl_LightModel.ambient.rgb * gl_FrontMaterial.diffuse.rgb;
+       vec3 diffuse = gl_FrontMaterial.diffuse.rgb * lumel * 1.8;
+#endif
+
+#ifdef USE_MIRROR
+       vec3 refl = texture2D(mirrortex, gl_FragCoord.xy * mirtex_scale).rgb;
+       diffuse += refl * reflectivity; // just add it to diffuse until we get another source of specularity
+#endif
+
+       gl_FragColor.rgb = ambient + diffuse;
+       gl_FragColor.a = gl_FrontMaterial.diffuse.a;
+}