From 6d9168150d131a0b964d26dcddfc2dc2bebe5730 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Wed, 5 Dec 2012 20:29:58 +0000 Subject: [PATCH] Fix random buildings after latest procedural texture changes. --- Effects/building.eff | 18 ++++++++++---- Shaders/building-haze.vert | 48 +++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Effects/building.eff b/Effects/building.eff index 9a7b8bde5..84e0383cf 100644 --- a/Effects/building.eff +++ b/Effects/building.eff @@ -147,10 +147,10 @@ - Shaders/include_fog.vert - Shaders/building-default.vert - Shaders/include_fog.frag - Shaders/terrain-nocolor.frag + Shaders/include_fog.vert + Shaders/building-default.vert + Shaders/include_fog.frag + Shaders/terrain-nocolor.frag texture @@ -236,6 +236,16 @@ float eye_alt + + cloud_self_shading + float + cloud_self_shading + + + moonlight + float + moonlight + texture sampler-2d diff --git a/Shaders/building-haze.vert b/Shaders/building-haze.vert index 2ce4c669e..95912ca2a 100644 --- a/Shaders/building-haze.vert +++ b/Shaders/building-haze.vert @@ -26,10 +26,7 @@ varying vec3 relPos; //varying float yprime; //varying float vertex_alt; varying float yprime_alt; -varying float mie_angle; - - - +//varying float mie_angle; uniform int colorMode; uniform float hazeLayerAltitude; @@ -48,6 +45,8 @@ const float terminator_width = 200000.0; float earthShade; +float mie_angle; + float light_func (in float x, in float a, in float b, in float c, in float d, in float e) { @@ -66,12 +65,12 @@ void main() vec4 light_diffuse; vec4 light_ambient; - //float yprime_alt; float yprime; float lightArg; float intensity; float vertex_alt; float scattering; + vec3 shadedFogColor = vec3(0.65, 0.67, 0.78); // this code is copied from default.vert @@ -161,27 +160,23 @@ if (terminator < 1000000.0) // the full, sunrise and sunset computation light_diffuse.b = light_func(lightArg, 1.330e-05, 0.264, 3.827, 1.08e-05, 1.0); light_diffuse.g = light_func(lightArg, 3.931e-06, 0.264, 3.827, 7.93e-06, 1.0); light_diffuse.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0); - light_diffuse.a = 0.0; + light_diffuse.a = 1.0; light_diffuse = light_diffuse * scattering; - light_ambient.b = light_func(lightArg, 0.000506, 0.131, -3.315, 0.000457, 0.5); - light_ambient.g = light_func(lightArg, 2.264e-05, 0.134, 0.967, 3.66e-05, 0.4); light_ambient.r = light_func(lightArg, 0.236, 0.253, 1.073, 0.572, 0.33); - light_ambient.a = 0.0; - - - + light_ambient.g = light_ambient.r * 0.4/0.33; + light_ambient.b = light_ambient.r * 0.5/0.33; + light_ambient.a = 1.0; // correct ambient light intensity and hue before sunrise if (earthShade < 0.5) { - light_ambient = light_ambient * (0.7 + 0.3 * smoothstep(0.2, 0.5, earthShade)); - intensity = length(light_ambient.xyz); + //light_ambient = light_ambient * (0.4 + 0.6 * smoothstep(0.2, 0.5, earthShade)); + intensity = length(light_ambient.rgb); + light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.8,earthShade) )); - light_ambient.xyz = intensity * normalize(mix(light_ambient.xyz, vec3 (0.45, 0.6, 0.8), 1.0 -smoothstep(0.1, 0.8,earthShade) )); - - intensity = length(light_diffuse.xyz); - light_diffuse.xyz = intensity * normalize(mix(light_diffuse.xyz, vec3 (0.45, 0.6, 0.8), 1.0 -smoothstep(0.1, 0.7,earthShade) )); + intensity = length(light_diffuse.rgb); + light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) )); } @@ -213,8 +208,8 @@ else // the faster, full-day version without lightfields mie_angle = 1.0; if (terminator > 3000000.0) - {light_diffuse = vec4 (1.0, 1.0, 1.0, 0.0); - light_ambient = vec4 (0.33, 0.4, 0.5, 0.0); } + {light_diffuse = vec4 (1.0, 1.0, 1.0, 1.0); + light_ambient = vec4 (0.33, 0.4, 0.5, 1.0); } else { @@ -222,12 +217,12 @@ else // the faster, full-day version without lightfields light_diffuse.b = 0.78 + lightArg * 0.21; light_diffuse.g = 0.907 + lightArg * 0.091; light_diffuse.r = 0.904 + lightArg * 0.092; - light_diffuse.a = 0.0; + light_diffuse.a = 1.0; - light_ambient.b = 0.41 + lightArg * 0.08; - light_ambient.g = 0.333 + lightArg * 0.06; light_ambient.r = 0.316 + lightArg * 0.016; - light_ambient.a = 0.0; + light_ambient.g = light_ambient.r * 0.4/0.33; + light_ambient.b = light_ambient.r * 0.5/0.33; + light_ambient.a = 1.0; } light_diffuse = light_diffuse * scattering; @@ -248,7 +243,8 @@ else // the faster, full-day version without lightfields diffuse_term.a = 1.0; // Another hack for supporting two-sided lighting without using // gl_FrontFacing in the fragment shader. - gl_FrontColor.rgb = constant_term.rgb; gl_FrontColor.a = 1.0; - gl_BackColor.rgb = constant_term.rgb; gl_BackColor.a = 0.0; + gl_FrontColor.rgb = constant_term.rgb; + gl_BackColor.rgb = constant_term.rgb; + gl_FrontColor.a = mie_angle; gl_BackColor.a = mie_angle; }