From e21807bb332bd5bf9dd8f44551ce96f42d718da8 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc <emilianh@gmail.com> Date: Thu, 17 May 2012 20:10:30 +0300 Subject: [PATCH] formatting cleanup Signed-off-by: Emilian Huminiuc <emilianh@gmail.com> --- Shaders/transition.frag | 66 ++++++++++++++++++++++++++++++----------- Shaders/ubershader.frag | 10 +++---- 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/Shaders/transition.frag b/Shaders/transition.frag index 523813936..01c3872b7 100644 --- a/Shaders/transition.frag +++ b/Shaders/transition.frag @@ -4,13 +4,27 @@ // � Emilian Huminiuc 2011 // Ambient term comes in gl_Color.rgb. -varying vec4 diffuse_term, RawPos; -varying vec3 Vnormal, normal; -//varying float fogCoord; +varying vec4 diffuse_term; +varying vec4 RawPos; +varying vec3 normal; +varying vec3 Vnormal; + +uniform float SnowLevel; +uniform float Transitions; +uniform float InverseSlope; +uniform float RainNorm; + +uniform float CloudCover0; +uniform float CloudCover1; +uniform float CloudCover2; +uniform float CloudCover3; +uniform float CloudCover4; + +uniform sampler2D BaseTex; +uniform sampler2D SecondTex; +uniform sampler2D ThirdTex; +uniform sampler2D SnowTex; -uniform float SnowLevel, Transitions, InverseSlope, RainNorm; -uniform float CloudCover0, CloudCover1, CloudCover2, CloudCover3, CloudCover4; -uniform sampler2D BaseTex, SecondTex, ThirdTex, SnowTex; uniform sampler3D NoiseTex; ////fog "include" ///// @@ -21,10 +35,25 @@ vec3 fog_Func(vec3 color, int type); void main() { - float MixFactor, NdotL, NdotHV, fogFactor, cover, slope, L1, L2, wetness; + float MixFactor; + float NdotL; + float NdotHV; + float fogFactor; + float cover; + float slope; + float L1; + float L2; + float wetness; - vec3 n, lightDir, halfVector; - vec4 texel, fragColor, color, specular, Noise; + vec3 n; + vec3 lightDir; + vec3 halfVector; + + vec4 texel; + vec4 fragColor; + vec4 color; + vec4 specular; + vec4 Noise; lightDir = gl_LightSource[0].position.xyz; halfVector = gl_LightSource[0].halfVector.xyz; @@ -68,9 +97,10 @@ void main() //pull the texture fetch outside flow control to fix aliasing artefacts :( vec4 baseTexel = texture2D(BaseTex, gl_TexCoord[0].st); - vec4 secondTexel = texture2D(SecondTex, gl_TexCoord[0].st); - vec4 thirdTexel = texture2D(ThirdTex, gl_TexCoord[0].st); - vec4 snowTexel = texture2D(SnowTex, gl_TexCoord[0].st); + vec4 secondTexel = texture2D(SecondTex, gl_TexCoord[0].st); + vec4 thirdTexel = texture2D(ThirdTex, gl_TexCoord[0].st); + vec4 snowTexel = texture2D(SnowTex, gl_TexCoord[0].st); + //Normal transition. For more abrupt faces apply another texture (or 2). if (InverseSlope == 0.0) { //Do we do an intermediate transition @@ -123,11 +153,14 @@ void main() wetness = 1.0 - 0.3 * RainNorm; texel.rgb = texel.rgb * wetness; - - float altitude = RawPos.z; + float altitude = RawPos.z; //Snow texture for areas higher than SnowLevel if (altitude >= SnowLevel - (1000.0 * slope + 300.0 * MixFactor) && slope > L2 - 0.12) { - texel = mix(texel, mix(texel, snowTexel, smoothstep(L2 - 0.09 * MixFactor, L2, slope)), smoothstep(SnowLevel - (1000.0 * slope + 300.0 * MixFactor), SnowLevel - (1000.0 * slope - 150.0 * MixFactor), altitude)); + texel = mix(texel, mix(texel, snowTexel, smoothstep(L2 - 0.09 * MixFactor, L2, slope)), + smoothstep(SnowLevel - (1000.0 * slope + 300.0 * MixFactor), + SnowLevel - (1000.0 * slope - 150.0 * MixFactor), + altitude) + ); } fragColor = color * texel + specular; @@ -142,6 +175,5 @@ void main() //fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); fragColor.rgb *= 1.2 - 0.4 * MixFactor; fragColor.rgb = fog_Func(fragColor.rgb, fogType); - //gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); gl_FragColor = fragColor; - } + } diff --git a/Shaders/ubershader.frag b/Shaders/ubershader.frag index 206615a5a..f674f9d1b 100644 --- a/Shaders/ubershader.frag +++ b/Shaders/ubershader.frag @@ -70,8 +70,8 @@ void main (void) vec4 lightmapTexel = texture2D(LightMapTex, gl_TexCoord[0].st); vec3 mixedcolor; - vec3 N; - float pf; + vec3 N = vec3(0.0,0.0,1.0); + float pf = 0.0; ///BEGIN bump if (nmap_enabled > 0 && shader_qual > 2){ @@ -114,7 +114,7 @@ void main (void) //BEGIN reflect //////////////////////////////////////////////////////////////////// if (refl_enabled > 0 && shader_qual > 1){ - float reflFactor; + float reflFactor = 0.0; float transparency_offset = clamp(refl_correction, -1.0, 1.0);// set the user shininess offset if(refl_map > 0){ @@ -174,15 +174,13 @@ void main (void) color.a = texel.a * alpha; vec4 fragColor = vec4(color.rgb * mixedcolor + ambient_Correction.rgb, color.a); - - fragColor += Specular * nmap.a; ////////////////////////////////////////////////////////////////////// // BEGIN lightmap ////////////////////////////////////////////////////////////////////// if ( lightmap_enabled >= 1 ) { - vec3 lightmapcolor; + vec3 lightmapcolor = vec3(0.0); vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, lightmap_b_factor, lightmap_a_factor); lightmapFactor = lightmapFactor * lightmapTexel;