1
0
Fork 0

ALS model effect accepts a snow flag to let OSM building roofs be snow-covered in winter

This commit is contained in:
Thorsten Renk 2017-06-03 18:01:02 +03:00
parent 7c44bf6721
commit a7b916a244
3 changed files with 59 additions and 4 deletions

View file

@ -22,6 +22,8 @@
<lightmap-factor type="float" n="2">0</lightmap-factor> <lightmap-factor type="float" n="2">0</lightmap-factor>
<lightmap-factor type="float" n="3">0</lightmap-factor> <lightmap-factor type="float" n="3">0</lightmap-factor>
<snow-enabled type="int">1</snow-enabled>
<!-- <!--
<lightmap-factor type="float" n="3">1</lightmap-factor> <lightmap-factor type="float" n="3">1</lightmap-factor>
<lightmap-color type="vec3d" n="3"> 1 1 1 </lightmap-color> <lightmap-color type="vec3d" n="3"> 1 1 1 </lightmap-color>

View file

@ -104,6 +104,7 @@ please see Docs/README.model-combined.eff for documentation
<!-- END Grain texture --> <!-- END Grain texture -->
<!-- simulate rain effects --> <!-- simulate rain effects -->
<rain-enabled type="int">0</rain-enabled> <rain-enabled type="int">0</rain-enabled>
<snow-enabled type="int">0</snow-enabled>
<!-- Dirt --> <!-- Dirt -->
<dirt-enabled type="int">0</dirt-enabled> <dirt-enabled type="int">0</dirt-enabled>
<dirt-multi type="int">0</dirt-multi> <dirt-multi type="int">0</dirt-multi>
@ -147,6 +148,8 @@ please see Docs/README.model-combined.eff for documentation
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype> <fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
<wetness><use>/environment/surface/wetness</use></wetness> <wetness><use>/environment/surface/wetness</use></wetness>
<rnorm><use>/environment/rain-norm</use></rnorm> <rnorm><use>/environment/rain-norm</use></rnorm>
<snow_level><use>/environment/snow-level-m</use></snow_level>
<snow_thickness_factor><use>/environment/surface/snow-thickness-factor</use></snow_thickness_factor>
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x> <cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y> <cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
<cloudpos2_x><use>/local-weather/cloud-shadows/cloudpos-x[1]</use></cloudpos2_x> <cloudpos2_x><use>/local-weather/cloud-shadows/cloudpos-x[1]</use></cloudpos2_x>
@ -774,7 +777,7 @@ please see Docs/README.model-combined.eff for documentation
</value> </value>
</uniform> </uniform>
<!-- simulate wetness and rain--> <!-- simulate wetness, rain and snow -->
<uniform> <uniform>
<name>rain_enabled</name> <name>rain_enabled</name>
<type>int</type> <type>int</type>
@ -783,6 +786,26 @@ please see Docs/README.model-combined.eff for documentation
</value> </value>
</uniform> </uniform>
<uniform>
<name>snow_enabled</name>
<type>int</type>
<value>
<use>snow-enabled</use>
</value>
</uniform>
<uniform>
<name>snowlevel</name>
<type>float</type>
<value><use>snow_level</use></value>
</uniform>
<uniform>
<name>snow_thickness_factor</name>
<type>float</type>
<value><use>snow_thickness_factor</use></value>
</uniform>
<!-- set the amount of ambient light correction 0.0 - 1.0 --> <!-- set the amount of ambient light correction 0.0 - 1.0 -->
<uniform> <uniform>
<name>amb_correction</name> <name>amb_correction</name>

View file

@ -41,6 +41,7 @@ uniform int cloud_shadow_flag;
uniform int use_searchlight; uniform int use_searchlight;
uniform int use_landing_light; uniform int use_landing_light;
uniform int use_alt_landing_light; uniform int use_alt_landing_light;
uniform int snow_enabled;
uniform float amb_correction; uniform float amb_correction;
uniform float dirt_b_factor; uniform float dirt_b_factor;
@ -72,6 +73,8 @@ uniform float terminator;
uniform float terrain_alt; uniform float terrain_alt;
uniform float visibility; uniform float visibility;
uniform float air_pollution; uniform float air_pollution;
uniform float snowlevel;
uniform float snow_thickness_factor;
uniform float osg_SimulationTime; uniform float osg_SimulationTime;
@ -96,6 +99,7 @@ uniform vec3 dirt_g_color;
uniform vec3 dirt_b_color; uniform vec3 dirt_b_color;
float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density); float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
float Noise2D(in vec2 coord, in float wavelength);
float shadow_func (in float x, in float y, in float noise, in float dist); float shadow_func (in float x, in float y, in float noise, in float dist);
float fog_func (in float targ, in float altitude); float fog_func (in float targ, in float altitude);
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt); float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
@ -191,6 +195,7 @@ void main (void)
float ct = dot(normalize(up), normalize(vertVec)); float ct = dot(normalize(up), normalize(vertVec));
vec3 relPos = (gl_ModelViewMatrixInverse * vec4 (vertVec,0.0)).xyz;
/// END geometry for light /// END geometry for light
@ -241,6 +246,31 @@ void main (void)
/// END grain overlay /// END grain overlay
/// BEGIN snowcover
vec4 snow_texel = vec4 (0.95, 0.95, 0.95, 1.0);
if (snow_enabled == 1)
{
float noise_1m = Noise2D(rawpos.xy, 1.0);
float noise_5m = Noise2D(rawpos.xy, 5.0);
float noise_term = 0.5 * (noise_5m - 0.5);
noise_term += 0.5 * (noise_1m - 0.5);
snow_texel.a = snow_texel.a * 0.2+0.8* smoothstep(0.2,0.8, 0.3 +noise_term + 0.5*snow_thickness_factor +0.0001*(relPos.z +eye_alt -snowlevel) );
snow_texel.a *= smoothstep(0.5, 0.7,dot(VNormal, up));
float noise_2000m = 0.0;
float noise_10m = 0.0;
texel.rgb = mix(texel.rgb, snow_texel.rgb, snow_texel.a* smoothstep(snowlevel, snowlevel+200.0, 1.0 * (relPos.z + eye_alt)+ (noise_2000m + 0.1 * noise_10m -0.55) *400.0));
}
/// END snowcover
vec3 reflVecN; vec3 reflVecN;
///BEGIN bump ///BEGIN bump
@ -295,7 +325,7 @@ void main (void)
{pf1 = pow(nDotHV1, 0.5*gl_FrontMaterial.shininess);} {pf1 = pow(nDotHV1, 0.5*gl_FrontMaterial.shininess);}
vec3 relPos = (gl_ModelViewMatrixInverse * vec4 (vertVec,0.0)).xyz;
if (cloud_shadow_flag == 1) if (cloud_shadow_flag == 1)
{ {
float cloud_shadow_factor = shadow_func(relPos.x, relPos.y, 1.0, dist); float cloud_shadow_factor = shadow_func(relPos.x, relPos.y, 1.0, dist);