From fb58a3211f398a1228327bc804a972c1011ee5e4 Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Fri, 13 Jul 2012 17:44:53 +0300 Subject: [PATCH] some tweaks to runway shader Signed-off-by: Emilian Huminiuc --- Shaders/runway-gbuffer.frag | 12 ++++++------ Shaders/runway.frag | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Shaders/runway-gbuffer.frag b/Shaders/runway-gbuffer.frag index 683ce2454..6b0de159f 100644 --- a/Shaders/runway-gbuffer.frag +++ b/Shaders/runway-gbuffer.frag @@ -50,12 +50,12 @@ void main (void) if (normalmap_dds > 0) N = -N; - + float lightness = dot(texel.rgb, vec3( 0.3, 0.59, 0.11 )); // calculate the specular light - float refl_correction = spec_adjust * 1.9 - 1.0; + float refl_correction = spec_adjust * 2.5 - 1.0; float shininess = max (0.35, refl_correction) * nmap.a; - float specular = dot(vec3(0.5*shininess), vec3( 0.3, 0.59, 0.11 )); + float specular = dot(vec3(1.0) * lightness , vec3( 0.3, 0.59, 0.11 )); vec4 color = vec4(1.0); @@ -98,10 +98,10 @@ void main (void) vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness); vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0); - vec4 mixedcolor = mix(texel, raincolor, reflFactor); + vec4 mixedcolor = mix(texel, raincolor * (1.0 - refl_correction * (1.0 - lightness)), reflFactor); // the final reflection - vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction, color.a); + vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction * (1.0 - refl_correction * (1.0 - 0.8 * lightness)), color.a); - encode_gbuffer(N, fragColor.rgb, 1, specular, shininess, emission, gl_FragCoord.z); + encode_gbuffer(N, fragColor.rgb, 254, specular, shininess, emission, gl_FragCoord.z); } \ No newline at end of file diff --git a/Shaders/runway.frag b/Shaders/runway.frag index 463c1246b..d4bb31d05 100644 --- a/Shaders/runway.frag +++ b/Shaders/runway.frag @@ -61,9 +61,9 @@ void main (void) if (normalmap_dds > 0) N = -N; - + float lightness = dot(texel.rgb, vec3( 0.3, 0.59, 0.11 )); // calculate the specular light - float refl_correction = spec_adjust * 1.9 - 1.0; + float refl_correction = spec_adjust * 2.5 - 1.0; float shininess = max (0.35, refl_correction); 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))); @@ -74,10 +74,12 @@ void main (void) pf = pow(nDotHV, /*gl_FrontMaterial.*/shininess); vec4 Diffuse = gl_LightSource[0].diffuse * nDotVP; - vec4 Specular = vec4(vec3(0.5*shininess), 1.0)* gl_LightSource[0].specular * pf; + //vec4 Specular = vec4(vec3(0.5*shininess), 1.0)* gl_LightSource[0].specular * pf; + vec4 Specular = vec4(1.0)* lightness * gl_LightSource[0].specular * pf; vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse; - color += Specular * vec4(vec3(0.5*shininess), 1.0) * nmap.a; + //color += Specular * vec4(vec3(0.5*shininess), 1.0) * nmap.a; + color += Specular * vec4(1.0) * nmap.a; color.a = texel.a * alpha; color = clamp(color, 0.0, 1.0); @@ -119,10 +121,11 @@ void main (void) vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0); raincolor += Specular * nmap.a; - vec4 mixedcolor = mix(texel, raincolor, reflFactor); + + vec4 mixedcolor = mix(texel, raincolor * (1.0 - refl_correction * (1.0 - lightness)), reflFactor); //* (1.0 - 0.5 * transparency_offset ) // the final reflection - vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction.rgb, color.a); + vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction.rgb * (1.0 - refl_correction * (1.0 - 0.8 * lightness)), color.a); fragColor += Specular * nmap.a; fragColor.rgb = fog_Func(fragColor.rgb, fogType);