Add intensity-factor to lightmap shader
This commit is contained in:
parent
bd67875475
commit
bef7c3b04b
2 changed files with 15 additions and 5 deletions
|
@ -9,7 +9,8 @@
|
||||||
<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>
|
<condition><use>/sim/rendering/shader-effects</use></condition>
|
||||||
|
<factor>1</factor>
|
||||||
</parameters>
|
</parameters>
|
||||||
<technique n="10">
|
<technique n="10">
|
||||||
<predicate>
|
<predicate>
|
||||||
|
@ -104,6 +105,11 @@
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
<value><use>condition</use></value>
|
<value><use>condition</use></value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>lightmap_factor</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>factor</use></value>
|
||||||
|
</uniform>
|
||||||
</pass>
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
<technique n="11">
|
<technique n="11">
|
||||||
|
|
|
@ -9,10 +9,11 @@ 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;
|
||||||
|
|
||||||
|
// lightmap options
|
||||||
|
uniform float condition;
|
||||||
|
uniform float lightmap_factor;
|
||||||
uniform sampler2D lightmap_texture;
|
uniform sampler2D lightmap_texture;
|
||||||
|
|
||||||
float luminance(vec3 color)
|
float luminance(vec3 color)
|
||||||
|
@ -52,10 +53,13 @@ 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;
|
||||||
|
|
||||||
|
// The lightmap function
|
||||||
if ( condition >= 1 ) {
|
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);
|
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…
Add table
Reference in a new issue