diff --git a/Effects/cloud.eff b/Effects/cloud.eff index a7a6b061f..fa22fa610 100644 --- a/Effects/cloud.eff +++ b/Effects/cloud.eff @@ -11,6 +11,7 @@ /sim/rendering/eye-altitude-m /environment/cloud-self-shading /environment/moonlight + /environment/visibility-m @@ -106,6 +107,11 @@ float moonlight + + visibility + float + visibility + diff --git a/Nasal/local_weather/cloud_definitions.nas b/Nasal/local_weather/cloud_definitions.nas index e2fb8d341..e9e0a217a 100644 --- a/Nasal/local_weather/cloud_definitions.nas +++ b/Nasal/local_weather/cloud_definitions.nas @@ -245,7 +245,7 @@ else if (type == "Cumulus (whisp)"){ cloudAssembly.num_tex_y = 3; #characterize the cloud - cloudAssembly.bottom_shade = 0.9; + cloudAssembly.bottom_shade = 0.8; cloudAssembly.n_sprites = 4; cloudAssembly.min_width = 400.0 * mult; cloudAssembly.max_width = 600.0 * mult; @@ -383,7 +383,7 @@ else if (type == "Altocumulus"){ cloudAssembly.num_tex_y = 3; #characterize the cloud - cloudAssembly.bottom_shade = 0.8; + cloudAssembly.bottom_shade = 0.7; cloudAssembly.n_sprites = 10; cloudAssembly.min_width = 400.0 * mult; cloudAssembly.max_width = 700.0 * mult; @@ -806,7 +806,7 @@ else if (type == "Cb_box") { cloudAssembly.n_sprites = 3; cloudAssembly.min_cloud_width = 2200.0; cloudAssembly.min_cloud_height = 1200.0; - cloudAssembly.bottom_shade = 0.4; + cloudAssembly.bottom_shade = 0.6; cloudAssembly.z_scale = 1.0; } else @@ -817,7 +817,7 @@ else if (type == "Cb_box") { cloudAssembly.num_tex_y = 2; #characterize the cloud - cloudAssembly.bottom_shade = 0.4; + cloudAssembly.bottom_shade = 0.6; cloudAssembly.n_sprites = 6; cloudAssembly.min_width = 800.0; cloudAssembly.max_width = 1100.0; @@ -838,8 +838,8 @@ else if (type == "Cb_box") { cloudAssembly.num_tex_y = 2; #characterize the cloud - cloudAssembly.bottom_shade = 0.4; - cloudAssembly.n_sprites = 10; + cloudAssembly.bottom_shade = 0.6; + cloudAssembly.n_sprites = 20; cloudAssembly.min_width = 1000.0; cloudAssembly.max_width = 1500.0; cloudAssembly.min_height = 1000.0; diff --git a/Nasal/local_weather/compat_layer.nas b/Nasal/local_weather/compat_layer.nas index 3ea3a4b32..241a6921a 100644 --- a/Nasal/local_weather/compat_layer.nas +++ b/Nasal/local_weather/compat_layer.nas @@ -163,21 +163,24 @@ foreach (var l; layers) -# we store that information ourselves, so this should be zero +# we store that information ourselves, so this should be zero, but rain forces us to go for an offset setprop("/environment/clouds/layer[0]/elevation-ft",0.0); # layer wrapping off setprop("/sim/rendering/clouds3d-wrap",0); -# Basic Weather rain altitude limit off +# rain altitude limit off + props.globals.getNode("/environment/params/use-external-precipitation-level").setBoolValue("true"); +setprop("/sim/rendering/minimum-sky-visibility", 0.0); -# rain and snow off for clean startup +# just to be sure, set other parameters off compat_layer.setRain(0.0); compat_layer.setSnow(0.0); compat_layer.setLight(1.0); + } @@ -222,9 +225,10 @@ else var vis_goal = visibility_target; if (vis_goal > 1.03 * visibility_current) {vis_goal = 1.03 * visibility_current;} } - -setprop("/environment/visibility-m",vis_goal); -visibility_current = vis_goal; +# print(vis_goal, " ",local_weather.interpolated_conditions.visibility_m ); +if (local_weather.interpolated_conditions.visibility_m > vis_goal) + {setprop("/environment/visibility-m",vis_goal);} + visibility_current = vis_goal; settimer( func {visibility_loop(); },0); } diff --git a/Nasal/local_weather/local_weather.nas b/Nasal/local_weather/local_weather.nas index be4796893..6f600315a 100644 --- a/Nasal/local_weather/local_weather.nas +++ b/Nasal/local_weather/local_weather.nas @@ -605,7 +605,7 @@ if (realistic_visibility_flag == 1) vis_ovcst = vis_ovcst * 3.0; } -var inc1 = 0.1 * (vis_aloft - vis)/(vis_alt1 - ialt); +var inc1 = 0.0 * (vis_aloft - vis)/(vis_alt1 - ialt); var inc2 = 0.9 * (vis_aloft - vis)/1500.0; var inc3 = (vis_ovcst - vis_aloft)/(ovcst_alt_high - vis_alt1+1500); var inc4 = 0.5; @@ -636,6 +636,7 @@ else if (altitude > ovcst_alt_high) if (vis > max_vis_range) {vis = max_vis_range;} + # determine scattering shader parameters if scattering shader is on if (scattering_shader_flag == 1) @@ -760,6 +761,7 @@ local_weather.setOvercast(ovcst); # now check if an effect volume writes the property and set only if not +# but set visibility if interpolated is smaller than effect-specified var flag = getprop("local-weather/effect-volumes/number-active-vis"); @@ -767,6 +769,11 @@ if ((flag ==0) and (vis > 0.0) and (getprop(lw~"lift-loop-flag") == 0) and (comp { compat_layer.setVisibility(vis); } +else if (getprop("/local-weather/current/visibility-m") > vis) + { + compat_layer.setVisibility(vis); + } + @@ -1217,6 +1224,7 @@ if (ev.vis_flag ==1) # then set the new value in current and execute change cNode.getNode("visibility-m").setValue(vis); #compat_layer.setVisibility(vis); + #print(vis); compat_layer.setVisibilitySmoothly(vis); # then count the number of active volumes on entry (we need that to determine @@ -1230,6 +1238,7 @@ if (ev.vis_flag ==1) if (ev.rain_flag == 1) { var rain = ev.rain; + #print("Setting rain to:", rain); ev.rain_r = cNode.getNode("rain-norm").getValue(); cNode.getNode("rain-norm").setValue(rain); compat_layer.setRain(rain); @@ -1711,7 +1720,7 @@ settimer ( func { compat_layer.setOvercast(0.0); setprop(lwi~"ipoint-number",0); setprop(lwi~"atmosphere-ipoint-number", 0); - },0.1); + },0); setprop(lw~"tmp/presampling-status", "idle"); @@ -1866,8 +1875,9 @@ if (edge_bias > 0.0) {height_bias = height_bias + 15.0 *edge_bias + 20.0 * rand var create_cumulonimbus_cloud = func(lat, lon, alt, size) { -create_cloudbox("Cb_box", lat, lon, alt, 2500.0,2000.0, 1000.0,14, 0.2, 0.1, 3.4, 8, 0.8, 0.1, 8); +create_cloudbox("Cb_box", lat, lon, alt, 2500.0,2000.0, 1000.0,10, 0.2, 0.1, 1.0, 1, 0.8, 0.1, 6); +#create_cloudbox = func (type, blat, blon, balt, dx,dy,dz,n, f_core, r_core, h_core, n_core, f_bottom, h_bottom, n_bottom) } ########################################################### @@ -1877,7 +1887,7 @@ create_cloudbox("Cb_box", lat, lon, alt, 2500.0,2000.0, 1000.0,14, 0.2, 0.1, 3.4 var create_cumulonimbus_cloud_rain = func(lat, lon, alt, size, rain) { -create_cloudbox("Cb_box", lat, lon, alt, 2500.0,2000.0, 1000.0,14, 0.2, 0.1, 3.4, 8, 0.8, 0.1, 8); +create_cloudbox("Cb_box", lat, lon, alt, 2500.0,2000.0, 1000.0,10, 0.2, 0.1, 1.0, 1, 0.8, 0.1, 6); @@ -3384,7 +3394,6 @@ scattering_shader_flag = getprop("/sim/rendering/shaders/skydome"); air_pollution_norm = getprop("/environment/air-pollution-norm"); - } ########################################################### @@ -3705,6 +3714,7 @@ else if ((getprop("/environment/metar/valid") == 0) and (getprop(lw~"tmp/tile-ma set_wind_model_flag(); + if ((wind_model_flag == 3) or ((wind_model_flag ==5) and (getprop(lwi~"ipoint-number") == 0))) { if (metar_flag != 1) @@ -4058,7 +4068,7 @@ setlistener(lw~"tmp/convective-status", func {var s = size(clouds_path); compat_ setlistener(lw~"tmp/effect-thread-status", func {var s = size(effects_geo); effect_placement_loop(s); }); setlistener(lw~"tmp/presampling-status", func {manage_presampling(); }); -# setlistener(lw~"config/wind-model", func {set_wind_model_flag();}); +#setlistener(lw~"config/wind-model", func {set_wind_model_flag();}); setlistener(lw~"config/thermal-properties", func {set_texture_mix();}); setlistener(lw~"config/clouds-in-dynamics-loop", func {weather_dynamics.max_clouds_in_loop = int(getprop(lw~"config/clouds-in-dynamics-loop"));}); @@ -4572,7 +4582,7 @@ setprop(lw~"effect-volumes/number-active-sat",0); # setprop(lw~"config/max-vis-range-m", 120000.0); setprop(lw~"config/temperature-offset-degc", 0.0); -#setprop("/sim/rendering/eye-altitude-m", getprop("/position/altitude-ft") * ft_to_m); +# setprop("/sim/rendering/eye-altitude-m", getprop("/position/altitude-ft") * ft_to_m); # create properties for tile management diff --git a/Nasal/local_weather/weather_tiles.nas b/Nasal/local_weather/weather_tiles.nas index b08d98eaa..2f48252db 100644 --- a/Nasal/local_weather/weather_tiles.nas +++ b/Nasal/local_weather/weather_tiles.nas @@ -1056,7 +1056,7 @@ else if (rn >0.4) create_2_8_tstratus(blat, blon, alt+alt_offset+8000,alpha); # and specify the atmosphere - local_weather.set_atmosphere_ipoint(blat, blon, vis + 17000.0, alt+alt_offset, vis + 25000.0, 0.35, alt+alt_offset +10000.0, alt+alt_offset + 20000.0, 0.65, alt+alt_offset, alt+alt_offset + 2500.0); + local_weather.set_atmosphere_ipoint(blat, blon, vis + 17000.0, alt+alt_offset, vis + 25000.0, 0.35, alt+alt_offset +10000.0, alt+alt_offset + 20000.0, 0.75, alt+alt_offset, alt+alt_offset + 2500.0); } else if (rn >0.2) { @@ -1068,7 +1068,7 @@ else if (rn >0.2) create_2_8_sstratus(blat, blon, alt+alt_offset+6000,alpha); # and specify the atmosphere - local_weather.set_atmosphere_ipoint(blat, blon, vis + 15000.0, alt+alt_offset, vis + 24000.0, 0.2, alt+alt_offset +15000.0, alt+alt_offset + 22000.0, 0.6, alt+alt_offset, alt+alt_offset + 2500.0); + local_weather.set_atmosphere_ipoint(blat, blon, vis + 15000.0, alt+alt_offset, vis + 24000.0, 0.2, alt+alt_offset +15000.0, alt+alt_offset + 22000.0, 0.7 - rand() * 0.1, alt+alt_offset, alt+alt_offset + 2500.0); } else if (rn >0.0) { @@ -1579,7 +1579,7 @@ calc_geo(blat); var vis = 9000.0 + rand() * 10000.0; var T = 10.0 + rand() * 15.0; -var spread = 8.0 + 2.0 * rand(); +var spread = 6.0 + 2.0 * rand(); var D = T - spread; var p = 1000 + rand() * 10.0; p = adjust_p(p); @@ -1598,7 +1598,7 @@ local_weather.convective_size_bias = 0.3 + rand() * 0.3; # and specify the atmosphere - local_weather.set_atmosphere_ipoint(blat, blon, vis + 12000.0, alt+alt_offset, vis + 20000.0, 0.0, alt+alt_offset +20000.0, alt+alt_offset + 25000.0, 0.65, alt+alt_offset, alt+alt_offset + 2500.0); + local_weather.set_atmosphere_ipoint(blat, blon, vis + 12000.0, alt+alt_offset, vis + 20000.0, 0.0, alt+alt_offset +20000.0, alt+alt_offset + 25000.0, 0.85, alt+alt_offset, alt+alt_offset + 2500.0); var rn = rand(); @@ -2584,13 +2584,13 @@ var set_METAR_weather_station = func { if (coverage_shade < 1) # clear sky, we need to specify an altitude for the model {shade = 0.9; alt_shade = 9000.0;} else if (coverage_shade < 3) - {shade = 0.8;} + {shade = 0.85;} else if (coverage_shade < 5) - {shade = 0.7;} + {shade = 0.8;} else if (coverage_shade < 8) - {shade = 0.6;} + {shade = 0.75;} else if (coverage_shade == 8) - {shade = 0.55;} + {shade = 0.7;} shade = shade * coverage_mult; @@ -2761,6 +2761,7 @@ else else {create_8_8_nimbus_var3(lat, lon, alt, alpha);} } + if (rain > 0.1) { local_weather.create_effect_volume(3, lat, lon, 20000.0, 20000.0, alpha, 0.0, alt+900.0, 500.0 + (1.0 - 0.5 * rain) * 5500.0, 0.5 * rain , -1, -1, -1,0 ,0.95); @@ -3521,7 +3522,7 @@ if (rand() > 0.5) # we do a second thunderstorm # the convective layer -var strength = 0.3; +var strength = 0.10; var n = int(4000 * strength) * 0.5; local_weather.cumulus_exclusion_layer(lat, lon, alt, n, 20000.0, 20000.0, alpha, 0.3,2.5 , size(elat), elat, elon, erad); diff --git a/Shaders/3dcloud-lightfield.vert b/Shaders/3dcloud-lightfield.vert index 18fa59eef..a3e580bfe 100644 --- a/Shaders/3dcloud-lightfield.vert +++ b/Shaders/3dcloud-lightfield.vert @@ -10,6 +10,7 @@ uniform float scattering; uniform float terminator; uniform float altitude; uniform float cloud_self_shading; +uniform float visibility; uniform float moonlight; attribute vec3 usrAttr1; @@ -181,17 +182,19 @@ void main(void) // As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out. gl_FrontColor.a = min(smoothstep(10.0, 100.0, fogCoord), 1.0 - smoothstep(0.9 * range, range, fogCoord)); } + gl_FrontColor.a = gl_FrontColor.a * (1.0 - smoothstep(visibility, 3.0* visibility, fogCoord)); //gl_BackColor = gl_FrontColor; // Fog doesn't affect clouds as much as other objects. - float fadeScale = 0.05 + 0.2 * log(fogCoord/1000.0); - if (fadeScale < 0.05) fadeScale = 0.05; - fogFactor = exp( -gl_Fog.density * fogCoord * fadeScale); + //float fadeScale = 0.05 + 0.2 * log(fogCoord/1000.0); + //if (fadeScale < 0.05) fadeScale = 0.05; + //fogFactor = exp( -gl_Fog.density * fogCoord * fadeScale); // Fog doesn't affect clouds as much as other objects. //fogFactor = exp( -gl_Fog.density * fogCoord * 0.5); //fogFactor = clamp(fogFactor, 0.0, 1.0); + fogFactor = exp(-fogCoord/visibility); // haze of ground haze shader is slightly bluish hazeColor = light_diffuse.rgb;