1
0
Fork 0

Optional overlay texture for models

This commit is contained in:
Thorsten Renk 2013-04-22 11:32:28 +03:00
parent cea50f52ed
commit f62550e115
2 changed files with 73 additions and 18 deletions

View file

@ -89,6 +89,17 @@ please see Docs/README.model-combined.eff for documentation
</texture>
<reflection-noise type="float">0.25</reflection-noise>
<!-- END Reflection -->
<!-- grain texture -->
<grain-texture-enabled type="int">0</grain-texture-enabled>
<grain-magnification type="float">10</grain-magnification>
<texture n="14">
<image>Textures/Terrain/void.png</image>
<filter>linear-mipmap-linear</filter>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
<internal-format>normalized</internal-format>
</texture>
<!-- END Grain texture -->
<!-- Dirt -->
<dirt-enabled type="int">0</dirt-enabled>
<dirt-multi type="int">0</dirt-multi>
@ -348,7 +359,7 @@ please see Docs/README.model-combined.eff for documentation
</internal-format>
</texture-unit>
<!-- Reflection rainbow texture unit-->
<texture-unit>
<!--<texture-unit>
<unit>7</unit>
<image>
<use>texture[7]/image</use>
@ -365,26 +376,35 @@ please see Docs/README.model-combined.eff for documentation
<internal-format>
<use>texture[7]/internal-format</use>
</internal-format>
</texture-unit>
</texture-unit>-->
<!-- Grain texture -->
<texture-unit>
<unit>7</unit>
<image>
<use>texture[14]/image</use>
</image>
<filter>
<use>texture[14]/filter</use>
</filter>
<wrap-s>
<use>texture[14]/wrap-s</use>
</wrap-s>
<wrap-t>
<use>texture[14]/wrap-t</use>
</wrap-t>
<internal-format>
<use>texture[14]/internal-format</use>
</internal-format>
</texture-unit>
<vertex-program-two-side>
<use>vertex-program-two-side</use>
</vertex-program-two-side>
<program>
<!-- <vertex-shader n="0">Shaders/include_fog.vert</vertex-shader> -->
<vertex-shader n="1">Shaders/ubershader.vert</vertex-shader>
<!-- <fragment-shader n="0">Shaders/include_fog.frag</fragment-shader> -->
<fragment-shader n="1">Shaders/ubershader-lightfield.frag</fragment-shader>
<!--<attribute>
<name>tangent</name>
<index>6</index>
</attribute>
<attribute>
<name>binormal</name>
<index>7</index>
</attribute>-->
</program>
<uniform>
@ -429,13 +449,17 @@ please see Docs/README.model-combined.eff for documentation
<value type="int">6</value>
</uniform>
<uniform>
<!--<uniform>
<name>ReflRainbowTex</name>
<type>sampler-2d</type>
<value type="int">7</value>
</uniform>
</uniform>-->
<uniform>
<name>GrainTex</name>
<type>sampler-2d</type>
<value type="int">7</value>
</uniform>
<!-- NORMAL MAP -->
<!-- normalmap is used-->
@ -672,6 +696,24 @@ please see Docs/README.model-combined.eff for documentation
</value>
</uniform>
<!-- use a grain texture map-->
<uniform>
<name>grain_texture_enabled</name>
<type>int</type>
<value>
<use>grain-texture-enabled</use>
</value>
</uniform>
<uniform>
<name>grain_magnification</name>
<type>float</type>
<value>
<use>grain-magnification</use>
</value>
</uniform>
<!-- set the amount of ambient light correction 0.0 - 1.0 -->
<uniform>
<name>amb_correction</name>

View file

@ -22,9 +22,10 @@ uniform sampler2D LightMapTex;
uniform sampler2D NormalTex;
uniform sampler2D ReflFresnelTex;
uniform sampler2D ReflMapTex;
uniform sampler2D ReflRainbowTex;
//uniform sampler2D ReflRainbowTex;
uniform sampler3D ReflNoiseTex;
uniform samplerCube Environment;
uniform sampler2D GrainTex;
uniform int dirt_enabled;
uniform int dirt_multi;
@ -35,6 +36,7 @@ uniform int nmap_enabled;
uniform int refl_enabled;
uniform int refl_map;
uniform int shader_qual;
uniform int grain_texture_enabled;
uniform float amb_correction;
uniform float dirt_b_factor;
@ -49,6 +51,7 @@ uniform float refl_correction;
uniform float refl_fresnel;
uniform float refl_noise;
uniform float refl_rainbow;
uniform float grain_magnification;
uniform float avisibility;
@ -116,6 +119,8 @@ void main (void)
vec4 noisevec = texture3D(ReflNoiseTex, rawpos.xyz);
vec4 lightmapTexel = texture2D(LightMapTex, gl_TexCoord[0].st);
vec4 grainTexel;
vec3 mixedcolor;
vec3 N = vec3(0.0,0.0,1.0);
float pf = 0.0;
@ -203,6 +208,14 @@ void main (void)
/// END light
/// BEGIN grain overlay
if (grain_texture_enabled > 0)
{
grainTexel = texture2D(GrainTex, gl_TexCoord[0].st * grain_magnification);
texel.rgb = mix(texel.rgb, grainTexel.rgb, grainTexel.a );
}
/// END grain overlay
///BEGIN bump
if (nmap_enabled > 0 && shader_qual > 2){
N = nmap.rgb * 2.0 - 1.0;
@ -217,7 +230,7 @@ void main (void)
vec3 viewVec = normalize(vViewVec);
float v = abs(dot(viewVec, normalize(VNormal)));// Map a rainbowish color
vec4 fresnel = texture2D(ReflFresnelTex, vec2(v, 0.0));
vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0));
//vec4 rainbow = texture2D(ReflRainbowTex, vec2(v, 0.0));
float nDotVP = max(0.0, dot(N, normalize(gl_LightSource[0].position.xyz)));
float nDotHV = max(0.0, dot(N, normalize(gl_LightSource[0].halfVector.xyz)));
@ -262,7 +275,7 @@ void main (void)
reflFactor = clamp(reflFactor, 0.0, 1.0);
// add fringing fresnel and rainbow effects and modulate by reflection
vec4 reflcolor = mix(reflection, rainbow, refl_rainbow * v);
vec4 reflcolor = reflection;//mix(reflection, rainbow, refl_rainbow * v);
reflcolor += Specular * nmap.a;
vec4 reflfrescolor = mix(reflcolor, fresnel, refl_fresnel * v);
vec4 noisecolor = mix(reflfrescolor, noisevec, refl_noise);