From: John Tsiombikas Date: Sun, 18 Mar 2018 12:47:08 +0000 (+0200) Subject: forgot to add the new shader X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=commitdiff_plain;h=405378c467bd3b73532bb6a0ea45ff6bf712f539 forgot to add the new shader --- diff --git a/sdr/lightmap.p.glsl b/sdr/lightmap.p.glsl new file mode 100644 index 0000000..37b2abb --- /dev/null +++ b/sdr/lightmap.p.glsl @@ -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; +}