Lightmap conditional
This commit is contained in:
parent
aa15f24dd7
commit
f8fe1df22a
2 changed files with 13 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
|||
<material>
|
||||
<color-mode-uniform>1</color-mode-uniform> <!-- DIFFUSE -->
|
||||
</material>
|
||||
<condition><use>/sim/rendering/shader-effects</use></condition>
|
||||
</parameters>
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
|
@ -97,6 +98,11 @@
|
|||
<name>colorMode</name>
|
||||
<type>int</type>
|
||||
<value><use>material/color-mode-uniform</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>condition</name>
|
||||
<type>float</type>
|
||||
<value><use>condition</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
|
|
|
@ -9,6 +9,9 @@ varying vec4 diffuse_term;
|
|||
varying vec3 normal;
|
||||
varying float fogCoord;
|
||||
|
||||
// The conditional, to enable lightmapping
|
||||
uniform float condition;
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D lightmap_texture;
|
||||
|
||||
|
@ -49,8 +52,10 @@ void main()
|
|||
color = clamp(color, 0.0, 1.0);
|
||||
texel = texture2D(texture, gl_TexCoord[0].st);
|
||||
fragColor = color * texel + specular;
|
||||
vec3 lightmapTexel = texture2D(lightmap_texture, gl_TexCoord[0].st).rgb;
|
||||
fragColor.rgb = max(fragColor.rgb, lightmapTexel * gl_FrontMaterial.diffuse.rgb * texel.rgb);
|
||||
if ( condition >= 1 ) {
|
||||
vec3 lightmapTexel = texture2D(lightmap_texture, gl_TexCoord[0].st).rgb;
|
||||
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);
|
||||
}
|
Loading…
Reference in a new issue