From f62550e115f2962ab21f3d3ed5aea524c125c4e4 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Mon, 22 Apr 2013 11:32:28 +0300 Subject: [PATCH] Optional overlay texture for models --- Effects/model-combined.eff | 72 +++++++++++++++++++++++------- Shaders/ubershader-lightfield.frag | 19 ++++++-- 2 files changed, 73 insertions(+), 18 deletions(-) diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff index bc2b8e134..175c1d3e7 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -89,6 +89,17 @@ please see Docs/README.model-combined.eff for documentation 0.25 + + 0 + 10 + + Textures/Terrain/void.png + linear-mipmap-linear + repeat + repeat + normalized + + 0 0 @@ -348,7 +359,7 @@ please see Docs/README.model-combined.eff for documentation - + + + + 7 + + texture[14]/image + + + texture[14]/filter + + + texture[14]/wrap-s + + + texture[14]/wrap-t + + + texture[14]/internal-format + + vertex-program-two-side - Shaders/ubershader.vert - Shaders/ubershader-lightfield.frag - @@ -429,13 +449,17 @@ please see Docs/README.model-combined.eff for documentation 6 - + + + GrainTex + sampler-2d + 7 + @@ -672,6 +696,24 @@ please see Docs/README.model-combined.eff for documentation + + + + grain_texture_enabled + int + + grain-texture-enabled + + + + + grain_magnification + float + + grain-magnification + + + amb_correction diff --git a/Shaders/ubershader-lightfield.frag b/Shaders/ubershader-lightfield.frag index 210c37326..eed09f3d1 100644 --- a/Shaders/ubershader-lightfield.frag +++ b/Shaders/ubershader-lightfield.frag @@ -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);