Wind effects on vegetation for Atmospheric Light Scattering: movement of trees and hires terrain texture noise simulating vegetation and debris movement
This commit is contained in:
parent
ca5c8463ab
commit
b3bb82dd88
6 changed files with 124 additions and 25 deletions
|
@ -104,7 +104,9 @@
|
|||
<cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading>
|
||||
<moonlight><use>/environment/moonlight</use></moonlight>
|
||||
<season><use>/environment/season</use></season>
|
||||
<windspeed><use>/environment/wind-speed-kt</use></windspeed>
|
||||
<wind_effects><use>/sim/rendering/shaders/wind-effects</use></wind_effects>
|
||||
<windE><use>/environment/sea/surface/wind-from-east-fps</use></windE>
|
||||
<windN><use>/environment/sea/surface/wind-from-north-fps</use></windN>
|
||||
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
|
||||
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
|
||||
</parameters>
|
||||
|
@ -346,11 +348,6 @@
|
|||
<name>wetness</name>
|
||||
<type>float</type>
|
||||
<value><use>wetness</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>windspeed</name>
|
||||
<type>float</type>
|
||||
<value><use>windspeed</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>fogstructure</name>
|
||||
|
@ -372,6 +369,16 @@
|
|||
<type>float</type>
|
||||
<value><use>season</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>WindE</name>
|
||||
<type>float</type>
|
||||
<value><use>windE</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>WindN</name>
|
||||
<type>float</type>
|
||||
<value><use>windN</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>quality_level</name>
|
||||
<type>int</type>
|
||||
|
@ -381,6 +388,11 @@
|
|||
<name>tquality_level</name>
|
||||
<type>int</type>
|
||||
<value><use>tquality_level</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>wind_effects</name>
|
||||
<type>int</type>
|
||||
<value><use>wind_effects</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
|
||||
<fogstructure><use>/environment/fog-structure</use></fogstructure>
|
||||
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
|
||||
<wind_effects><use>/sim/rendering/shaders/wind-effects</use></wind_effects>
|
||||
<windE><use>/environment/sea/surface/wind-from-east-fps</use></windE>
|
||||
<windN><use>/environment/sea/surface/wind-from-north-fps</use></windN>
|
||||
<!-- END fog include -->
|
||||
</parameters>
|
||||
|
||||
|
@ -135,6 +138,16 @@
|
|||
<type>float</type>
|
||||
<value><use>season</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>WindE</name>
|
||||
<type>float</type>
|
||||
<value><use>windE</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>WindN</name>
|
||||
<type>float</type>
|
||||
<value><use>windN</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
|
@ -150,6 +163,11 @@
|
|||
<type>int</type>
|
||||
<value><use>quality_level</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>wind_effects</name>
|
||||
<type>int</type>
|
||||
<value><use>wind_effects</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
|
||||
|
@ -257,6 +275,16 @@
|
|||
<type>float</type>
|
||||
<value><use>season</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>WindE</name>
|
||||
<type>float</type>
|
||||
<value><use>windE</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>WindN</name>
|
||||
<type>float</type>
|
||||
<value><use>windN</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
<type>sampler-2d</type>
|
||||
|
@ -272,6 +300,11 @@
|
|||
<type>int</type>
|
||||
<value><use>quality_level</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>wind_effects</name>
|
||||
<type>int</type>
|
||||
<value><use>wind_effects</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ uniform float fogstructure;
|
|||
uniform float snow_thickness_factor;
|
||||
uniform float cloud_self_shading;
|
||||
uniform float season;
|
||||
uniform float windspeed;
|
||||
uniform float grain_strength;
|
||||
uniform float intrinsic_wetness;
|
||||
uniform float transition_model;
|
||||
|
@ -52,9 +51,12 @@ uniform float hires_overlay_bias;
|
|||
uniform float dot_density;
|
||||
uniform float dot_size;
|
||||
uniform float dust_resistance;
|
||||
uniform float WindE;
|
||||
uniform float WindN;
|
||||
uniform float osg_SimulationTime;
|
||||
uniform int quality_level;
|
||||
uniform int tquality_level;
|
||||
uniform int wind_effects;
|
||||
|
||||
const float EarthRadius = 5800000.0;
|
||||
const float terminator_width = 200000.0;
|
||||
|
@ -272,6 +274,34 @@ float msl_altitude = (relPos.z + eye_alt);
|
|||
float intensity;
|
||||
|
||||
|
||||
|
||||
// Wind motion of the overlay noise simulating movement of vegetation and loose debris
|
||||
|
||||
vec2 windPos;
|
||||
|
||||
if (wind_effects > 1)
|
||||
{
|
||||
float windSpeed = length(vec2 (WindE,WindN)) /3.0480;
|
||||
// interfering sine wave wind pattern
|
||||
float sineTerm = sin(0.35 * windSpeed * osg_SimulationTime + 0.05 * (rawPos.x + rawPos.y));
|
||||
sineTerm = sineTerm + sin(0.3 * windSpeed * osg_SimulationTime + 0.04 * (rawPos.x + rawPos.y));
|
||||
sineTerm = sineTerm + sin(0.22 * windSpeed * osg_SimulationTime + 0.05 * (rawPos.x + rawPos.y));
|
||||
sineTerm = sineTerm/3.0;
|
||||
// non-linear amplification to simulate gusts
|
||||
sineTerm = sineTerm * sineTerm;//smoothstep(0.2, 1.0, sineTerm);
|
||||
|
||||
// wind starts moving dust and leaves at around 8 m/s
|
||||
float timeArg = 0.01 * osg_SimulationTime * windSpeed * smoothstep(8.0, 15.0, windSpeed);
|
||||
timeArg = timeArg + 0.02 * sineTerm;
|
||||
|
||||
windPos = vec2 (rawPos.x + WindN * timeArg, rawPos.y + WindE * timeArg);
|
||||
}
|
||||
else
|
||||
{
|
||||
windPos = rawPos.xy;
|
||||
}
|
||||
|
||||
|
||||
// get noise at different wavelengths
|
||||
|
||||
// used: 5m, 5m gradient, 10m, 10m gradient: heightmap of the closeup terrain, 10m also snow
|
||||
|
@ -287,7 +317,7 @@ float noise_10m = Noise2D(rawPos.xy, 10.0);
|
|||
float noise_5m = Noise2D(rawPos.xy ,5.0);
|
||||
float noise_2m = Noise2D(rawPos.xy ,2.0);
|
||||
float noise_1m = Noise2D(rawPos.xy ,1.0);
|
||||
float noise_01m = Noise2D(rawPos.xy, 0.1);
|
||||
float noise_01m = Noise2D(windPos.xy, 0.1);
|
||||
|
||||
float noisegrad_10m;
|
||||
float noisegrad_5m;
|
||||
|
@ -488,15 +518,7 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0))
|
|||
|
||||
texel.rgb = texel.rgb * (1.0 - 0.6 * combined_wetness);
|
||||
|
||||
// surf - terrain is too bad...
|
||||
/* foam_texel.rgb =vec3 (1.0, 1.0, 1.0);
|
||||
foam_texel.rg = 0.7 * foam_texel.rg +0.3 * noise_2m * foam_texel.rg;
|
||||
float surf_strength = 1.0 + windspeed/5.0;
|
||||
float surf_sine = sin(osg_SimulationTime+5.0*noise_25m);
|
||||
float surf_steepcorr = 1.0 -smoothstep(0.99,1.01,abs(steepness));
|
||||
float surf_alt = (relPos.z+eye_alt ) - 20.0 * surf_steepcorr ;//+ noise_10m * surf_steepcorr
|
||||
texel.rgb = mix(foam_texel.rgb, texel.rgb, smoothstep((0.3 +0.3*surf_strength+ surf_sine) * surf_steepcorr-20.0, (0.3+ surf_strength + surf_sine) * surf_steepcorr-19.0, surf_alt));
|
||||
*/
|
||||
|
||||
|
||||
// light computations
|
||||
|
||||
|
|
|
@ -18,27 +18,26 @@
|
|||
// the surface normal is passed in gl_{Front,Back}Color. The alpha
|
||||
// component is set to 1 for front, 0 for back in order to work around
|
||||
// bugs with gl_FrontFacing in the fragment shader.
|
||||
//varying vec4 diffuse_term;
|
||||
//varying vec3 normal;
|
||||
varying vec3 relPos;
|
||||
|
||||
//varying float earthShade;
|
||||
//varying float yprime;
|
||||
//varying float vertex_alt;
|
||||
|
||||
varying vec3 relPos;
|
||||
varying float yprime_alt;
|
||||
//varying float mie_angle;
|
||||
|
||||
uniform int colorMode;
|
||||
uniform int wind_effects;
|
||||
uniform float hazeLayerAltitude;
|
||||
uniform float terminator;
|
||||
uniform float terrain_alt;
|
||||
uniform float avisibility;
|
||||
uniform float visibility;
|
||||
uniform float overcast;
|
||||
//uniform float scattering;
|
||||
uniform float ground_scattering;
|
||||
uniform float snow_level;
|
||||
uniform float season;
|
||||
uniform float WindN;
|
||||
uniform float WindE;
|
||||
|
||||
uniform float osg_SimulationTime;
|
||||
|
||||
float earthShade;
|
||||
float mie_angle;
|
||||
|
@ -94,6 +93,14 @@ void main()
|
|||
// Rotation of the generic quad to specific one for the tree.
|
||||
position.xy = vec2(dot(position.xy, vec2(cr, sr)), dot(position.xy, vec2(-sr, cr)));
|
||||
|
||||
|
||||
// Shear by wind. Note that this only applies to the top vertices
|
||||
if (wind_effects > 0)
|
||||
{
|
||||
position.x = position.x + position.z * (sin(osg_SimulationTime * 1.8 + (gl_Color.x + gl_Color.y + gl_Color.z) * 0.01) + 1.0) * 0.0025 * WindN;
|
||||
position.y = position.y + position.z * (sin(osg_SimulationTime * 1.8 + (gl_Color.x + gl_Color.y + gl_Color.z) * 0.01) + 1.0) * 0.0025 * WindE;
|
||||
}
|
||||
|
||||
// Move to correct location (stored in gl_Color)
|
||||
position = position + gl_Color.xyz;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0);
|
||||
|
|
|
@ -173,6 +173,30 @@
|
|||
</empty>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>right</halign>
|
||||
<text>
|
||||
<label>Wind Effects</label>
|
||||
</text>
|
||||
<slider>
|
||||
<name>wind</name>
|
||||
<min>0.0</min>
|
||||
<max>2.0</max>
|
||||
<step>1.0</step>
|
||||
<fraction>0.17</fraction>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/shaders/wind-effects</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>wind</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<empty>
|
||||
<pref-width>55</pref-width>
|
||||
</empty>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<visible>
|
||||
|
|
|
@ -147,6 +147,7 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
<transition type="float" userarchive="y">1.0</transition>
|
||||
<urban type="float" userarchive="y">1.0</urban>
|
||||
<water type="float" userarchive="y">1.0</water>
|
||||
<wind-effects type="float" userarchive="y">0.0</wind-effects>
|
||||
<lights type="float" userarchive="y">1.0</lights>
|
||||
<quality-level-internal type="float" userarchive="y">1.0</quality-level-internal>
|
||||
</shaders>
|
||||
|
|
Loading…
Reference in a new issue