1
0
Fork 0

Updates to Advanced Weather and cloud shaders - better support for low visibility conditions, improved framerates for Thunderstorm scenario

This commit is contained in:
Thorsten Renk 2013-03-01 09:40:05 +02:00
parent 9ffb8a3d52
commit f2ebbbbc70
6 changed files with 55 additions and 31 deletions

View file

@ -11,6 +11,7 @@
<altitude><use>/sim/rendering/eye-altitude-m</use></altitude> <altitude><use>/sim/rendering/eye-altitude-m</use></altitude>
<cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading> <cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading>
<moonlight><use>/environment/moonlight</use></moonlight> <moonlight><use>/environment/moonlight</use></moonlight>
<visibility><use>/environment/visibility-m</use></visibility>
</parameters> </parameters>
<technique n="9"> <technique n="9">
@ -106,6 +107,11 @@
<type>float</type> <type>float</type>
<value><use>moonlight</use></value> <value><use>moonlight</use></value>
</uniform> </uniform>
<uniform>
<name>visibility</name>
<type>float</type>
<value><use>visibility</use></value>
</uniform>
<!--<vertex-program-two-side>true</vertex-program-two-side>--> <!--<vertex-program-two-side>true</vertex-program-two-side>-->
</pass> </pass>
</technique> </technique>

View file

@ -245,7 +245,7 @@ else if (type == "Cumulus (whisp)"){
cloudAssembly.num_tex_y = 3; cloudAssembly.num_tex_y = 3;
#characterize the cloud #characterize the cloud
cloudAssembly.bottom_shade = 0.9; cloudAssembly.bottom_shade = 0.8;
cloudAssembly.n_sprites = 4; cloudAssembly.n_sprites = 4;
cloudAssembly.min_width = 400.0 * mult; cloudAssembly.min_width = 400.0 * mult;
cloudAssembly.max_width = 600.0 * mult; cloudAssembly.max_width = 600.0 * mult;
@ -383,7 +383,7 @@ else if (type == "Altocumulus"){
cloudAssembly.num_tex_y = 3; cloudAssembly.num_tex_y = 3;
#characterize the cloud #characterize the cloud
cloudAssembly.bottom_shade = 0.8; cloudAssembly.bottom_shade = 0.7;
cloudAssembly.n_sprites = 10; cloudAssembly.n_sprites = 10;
cloudAssembly.min_width = 400.0 * mult; cloudAssembly.min_width = 400.0 * mult;
cloudAssembly.max_width = 700.0 * mult; cloudAssembly.max_width = 700.0 * mult;
@ -806,7 +806,7 @@ else if (type == "Cb_box") {
cloudAssembly.n_sprites = 3; cloudAssembly.n_sprites = 3;
cloudAssembly.min_cloud_width = 2200.0; cloudAssembly.min_cloud_width = 2200.0;
cloudAssembly.min_cloud_height = 1200.0; cloudAssembly.min_cloud_height = 1200.0;
cloudAssembly.bottom_shade = 0.4; cloudAssembly.bottom_shade = 0.6;
cloudAssembly.z_scale = 1.0; cloudAssembly.z_scale = 1.0;
} }
else else
@ -817,7 +817,7 @@ else if (type == "Cb_box") {
cloudAssembly.num_tex_y = 2; cloudAssembly.num_tex_y = 2;
#characterize the cloud #characterize the cloud
cloudAssembly.bottom_shade = 0.4; cloudAssembly.bottom_shade = 0.6;
cloudAssembly.n_sprites = 6; cloudAssembly.n_sprites = 6;
cloudAssembly.min_width = 800.0; cloudAssembly.min_width = 800.0;
cloudAssembly.max_width = 1100.0; cloudAssembly.max_width = 1100.0;
@ -838,8 +838,8 @@ else if (type == "Cb_box") {
cloudAssembly.num_tex_y = 2; cloudAssembly.num_tex_y = 2;
#characterize the cloud #characterize the cloud
cloudAssembly.bottom_shade = 0.4; cloudAssembly.bottom_shade = 0.6;
cloudAssembly.n_sprites = 10; cloudAssembly.n_sprites = 20;
cloudAssembly.min_width = 1000.0; cloudAssembly.min_width = 1000.0;
cloudAssembly.max_width = 1500.0; cloudAssembly.max_width = 1500.0;
cloudAssembly.min_height = 1000.0; cloudAssembly.min_height = 1000.0;

View file

@ -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); setprop("/environment/clouds/layer[0]/elevation-ft",0.0);
# layer wrapping off # layer wrapping off
setprop("/sim/rendering/clouds3d-wrap",0); 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"); 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.setRain(0.0);
compat_layer.setSnow(0.0); compat_layer.setSnow(0.0);
compat_layer.setLight(1.0); compat_layer.setLight(1.0);
} }
@ -222,9 +225,10 @@ else
var vis_goal = visibility_target; var vis_goal = visibility_target;
if (vis_goal > 1.03 * visibility_current) {vis_goal = 1.03 * visibility_current;} if (vis_goal > 1.03 * visibility_current) {vis_goal = 1.03 * visibility_current;}
} }
# print(vis_goal, " ",local_weather.interpolated_conditions.visibility_m );
setprop("/environment/visibility-m",vis_goal); if (local_weather.interpolated_conditions.visibility_m > vis_goal)
visibility_current = vis_goal; {setprop("/environment/visibility-m",vis_goal);}
visibility_current = vis_goal;
settimer( func {visibility_loop(); },0); settimer( func {visibility_loop(); },0);
} }

View file

@ -605,7 +605,7 @@ if (realistic_visibility_flag == 1)
vis_ovcst = vis_ovcst * 3.0; 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 inc2 = 0.9 * (vis_aloft - vis)/1500.0;
var inc3 = (vis_ovcst - vis_aloft)/(ovcst_alt_high - vis_alt1+1500); var inc3 = (vis_ovcst - vis_aloft)/(ovcst_alt_high - vis_alt1+1500);
var inc4 = 0.5; var inc4 = 0.5;
@ -636,6 +636,7 @@ else if (altitude > ovcst_alt_high)
if (vis > max_vis_range) if (vis > max_vis_range)
{vis = max_vis_range;} {vis = max_vis_range;}
# determine scattering shader parameters if scattering shader is on # determine scattering shader parameters if scattering shader is on
if (scattering_shader_flag == 1) 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 # 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"); 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); 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 # then set the new value in current and execute change
cNode.getNode("visibility-m").setValue(vis); cNode.getNode("visibility-m").setValue(vis);
#compat_layer.setVisibility(vis); #compat_layer.setVisibility(vis);
#print(vis);
compat_layer.setVisibilitySmoothly(vis); compat_layer.setVisibilitySmoothly(vis);
# then count the number of active volumes on entry (we need that to determine # 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) if (ev.rain_flag == 1)
{ {
var rain = ev.rain; var rain = ev.rain;
#print("Setting rain to:", rain);
ev.rain_r = cNode.getNode("rain-norm").getValue(); ev.rain_r = cNode.getNode("rain-norm").getValue();
cNode.getNode("rain-norm").setValue(rain); cNode.getNode("rain-norm").setValue(rain);
compat_layer.setRain(rain); compat_layer.setRain(rain);
@ -1711,7 +1720,7 @@ settimer ( func {
compat_layer.setOvercast(0.0); compat_layer.setOvercast(0.0);
setprop(lwi~"ipoint-number",0); setprop(lwi~"ipoint-number",0);
setprop(lwi~"atmosphere-ipoint-number", 0); setprop(lwi~"atmosphere-ipoint-number", 0);
},0.1); },0);
setprop(lw~"tmp/presampling-status", "idle"); 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) { 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) { 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"); 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(); set_wind_model_flag();
if ((wind_model_flag == 3) or ((wind_model_flag ==5) and (getprop(lwi~"ipoint-number") == 0))) if ((wind_model_flag == 3) or ((wind_model_flag ==5) and (getprop(lwi~"ipoint-number") == 0)))
{ {
if (metar_flag != 1) 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/effect-thread-status", func {var s = size(effects_geo); effect_placement_loop(s); });
setlistener(lw~"tmp/presampling-status", func {manage_presampling(); }); 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/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"));}); 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/max-vis-range-m", 120000.0);
setprop(lw~"config/temperature-offset-degc", 0.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 # create properties for tile management

View file

@ -1056,7 +1056,7 @@ else if (rn >0.4)
create_2_8_tstratus(blat, blon, alt+alt_offset+8000,alpha); create_2_8_tstratus(blat, blon, alt+alt_offset+8000,alpha);
# and specify the atmosphere # 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) 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); create_2_8_sstratus(blat, blon, alt+alt_offset+6000,alpha);
# and specify the atmosphere # 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) else if (rn >0.0)
{ {
@ -1579,7 +1579,7 @@ calc_geo(blat);
var vis = 9000.0 + rand() * 10000.0; var vis = 9000.0 + rand() * 10000.0;
var T = 10.0 + rand() * 15.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 D = T - spread;
var p = 1000 + rand() * 10.0; p = adjust_p(p); 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 # 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(); 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 if (coverage_shade < 1) # clear sky, we need to specify an altitude for the model
{shade = 0.9; alt_shade = 9000.0;} {shade = 0.9; alt_shade = 9000.0;}
else if (coverage_shade < 3) else if (coverage_shade < 3)
{shade = 0.8;} {shade = 0.85;}
else if (coverage_shade < 5) else if (coverage_shade < 5)
{shade = 0.7;} {shade = 0.8;}
else if (coverage_shade < 8) else if (coverage_shade < 8)
{shade = 0.6;} {shade = 0.75;}
else if (coverage_shade == 8) else if (coverage_shade == 8)
{shade = 0.55;} {shade = 0.7;}
shade = shade * coverage_mult; shade = shade * coverage_mult;
@ -2761,6 +2761,7 @@ else
else {create_8_8_nimbus_var3(lat, lon, alt, alpha);} else {create_8_8_nimbus_var3(lat, lon, alt, alpha);}
} }
if (rain > 0.1) 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); 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 # the convective layer
var strength = 0.3; var strength = 0.10;
var n = int(4000 * strength) * 0.5; 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); local_weather.cumulus_exclusion_layer(lat, lon, alt, n, 20000.0, 20000.0, alpha, 0.3,2.5 , size(elat), elat, elon, erad);

View file

@ -10,6 +10,7 @@ uniform float scattering;
uniform float terminator; uniform float terminator;
uniform float altitude; uniform float altitude;
uniform float cloud_self_shading; uniform float cloud_self_shading;
uniform float visibility;
uniform float moonlight; uniform float moonlight;
attribute vec3 usrAttr1; 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. // 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 = 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; //gl_BackColor = gl_FrontColor;
// Fog doesn't affect clouds as much as other objects. // Fog doesn't affect clouds as much as other objects.
float fadeScale = 0.05 + 0.2 * log(fogCoord/1000.0); //float fadeScale = 0.05 + 0.2 * log(fogCoord/1000.0);
if (fadeScale < 0.05) fadeScale = 0.05; //if (fadeScale < 0.05) fadeScale = 0.05;
fogFactor = exp( -gl_Fog.density * fogCoord * fadeScale); //fogFactor = exp( -gl_Fog.density * fogCoord * fadeScale);
// Fog doesn't affect clouds as much as other objects. // Fog doesn't affect clouds as much as other objects.
//fogFactor = exp( -gl_Fog.density * fogCoord * 0.5); //fogFactor = exp( -gl_Fog.density * fogCoord * 0.5);
//fogFactor = clamp(fogFactor, 0.0, 1.0); //fogFactor = clamp(fogFactor, 0.0, 1.0);
fogFactor = exp(-fogCoord/visibility);
// haze of ground haze shader is slightly bluish // haze of ground haze shader is slightly bluish
hazeColor = light_diffuse.rgb; hazeColor = light_diffuse.rgb;