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