1
0
Fork 0

Add intensity-factor to lightmap shader

This commit is contained in:
Gijs de Rooy 2011-06-10 18:51:30 +02:00
parent bd67875475
commit bef7c3b04b
2 changed files with 15 additions and 5 deletions

View file

@ -9,7 +9,8 @@
<material>
<color-mode-uniform>1</color-mode-uniform> <!-- DIFFUSE -->
</material>
<condition><use>/sim/rendering/shader-effects</use></condition>
<condition><use>/sim/rendering/shader-effects</use></condition>
<factor>1</factor>
</parameters>
<technique n="10">
<predicate>
@ -104,6 +105,11 @@
<type>float</type>
<value><use>condition</use></value>
</uniform>
<uniform>
<name>lightmap_factor</name>
<type>float</type>
<value><use>factor</use></value>
</uniform>
</pass>
</technique>
<technique n="11">

View file

@ -9,10 +9,11 @@ varying vec4 diffuse_term;
varying vec3 normal;
varying float fogCoord;
// The conditional, to enable lightmapping
uniform float condition;
uniform sampler2D texture;
// lightmap options
uniform float condition;
uniform float lightmap_factor;
uniform sampler2D lightmap_texture;
float luminance(vec3 color)
@ -52,10 +53,13 @@ void main()
color = clamp(color, 0.0, 1.0);
texel = texture2D(texture, gl_TexCoord[0].st);
fragColor = color * texel + specular;
// The lightmap function
if ( condition >= 1 ) {
vec3 lightmapTexel = texture2D(lightmap_texture, gl_TexCoord[0].st).rgb;
vec3 lightmapTexel = texture2D(lightmap_texture, gl_TexCoord[0].st).rgb * lightmap_factor;
fragColor.rgb = max(fragColor.rgb, lightmapTexel * gl_FrontMaterial.diffuse.rgb * texel.rgb);
}
fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord);
gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor);
}