diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index cbf5b2440..e3d0e93e2 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -104,7 +104,9 @@ /environment/cloud-self-shading /environment/moonlight /environment/season - /environment/wind-speed-kt + /sim/rendering/shaders/wind-effects + /environment/sea/surface/wind-from-east-fps + /environment/sea/surface/wind-from-north-fps /sim/rendering/shaders/landmass /sim/rendering/shaders/transition @@ -346,11 +348,6 @@ wetness float wetness - - - windspeed - float - windspeed fogstructure @@ -372,6 +369,16 @@ float season + + WindE + float + windE + + + WindN + float + windN + quality_level int @@ -382,6 +389,11 @@ int tquality_level + + wind_effects + int + wind_effects + texture sampler-2d diff --git a/Effects/tree.eff b/Effects/tree.eff index 5c2d8b95b..a458b2e26 100644 --- a/Effects/tree.eff +++ b/Effects/tree.eff @@ -33,6 +33,9 @@ /sim/rendering/shaders/skydome /environment/fog-structure /sim/rendering/shaders/landmass + /sim/rendering/shaders/wind-effects + /environment/sea/surface/wind-from-east-fps + /environment/sea/surface/wind-from-north-fps @@ -135,6 +138,16 @@ float season + + WindE + float + windE + + + WindN + float + windN + texture sampler-2d @@ -150,6 +163,11 @@ int quality_level + + wind_effects + int + wind_effects + @@ -257,6 +275,16 @@ float season + + WindE + float + windE + + + WindN + float + windN + texture sampler-2d @@ -272,6 +300,11 @@ int quality_level + + wind_effects + int + wind_effects + diff --git a/Shaders/terrain-haze-ultra.frag b/Shaders/terrain-haze-ultra.frag index 51984fac4..cf36b863a 100644 --- a/Shaders/terrain-haze-ultra.frag +++ b/Shaders/terrain-haze-ultra.frag @@ -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 diff --git a/Shaders/tree-haze.vert b/Shaders/tree-haze.vert index f16ea2ebf..18c02e1e7 100644 --- a/Shaders/tree-haze.vert +++ b/Shaders/tree-haze.vert @@ -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); diff --git a/gui/dialogs/shaders-lightfield.xml b/gui/dialogs/shaders-lightfield.xml index 5273ca80c..fe49dad50 100644 --- a/gui/dialogs/shaders-lightfield.xml +++ b/gui/dialogs/shaders-lightfield.xml @@ -172,6 +172,30 @@ 55 + + + hbox + right + + + + + wind + 0.0 + 2.0 + 1.0 + 0.17 + true + /sim/rendering/shaders/wind-effects + + dialog-apply + wind + + + + 55 + + hbox diff --git a/preferences.xml b/preferences.xml index db348837c..a52c6f02d 100644 --- a/preferences.xml +++ b/preferences.xml @@ -147,6 +147,7 @@ Started September 2000 by David Megginson, david@megginson.com 1.0 1.0 1.0 + 0.0 1.0 1.0