ALS volumetric grass responds to wind
This commit is contained in:
parent
6dd9f6e8d9
commit
290f22d5ef
2 changed files with 39 additions and 46 deletions
|
@ -4,30 +4,7 @@
|
|||
<inherits-from>Effects/airfield</inherits-from>
|
||||
|
||||
<parameters>
|
||||
<!--<texture n="13">
|
||||
<image>Textures/Terrain/airport_grass2.png</image>
|
||||
<type>2d</type>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>repeat</wrap-s>
|
||||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
<texture n="14">
|
||||
<image>Textures/Terrain/void.png</image>
|
||||
<type>2d</type>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>repeat</wrap-s>
|
||||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
<texture n="15">
|
||||
<image>Textures/Terrain/void.png</image>
|
||||
<type>2d</type>
|
||||
<filter>linear-mipmap-linear</filter>
|
||||
<wrap-s>repeat</wrap-s>
|
||||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>-->
|
||||
|
||||
<texture n="20">
|
||||
<image>Textures/Terrain/airport-grass-autumn.png</image>
|
||||
<type>2d</type>
|
||||
|
@ -37,22 +14,13 @@
|
|||
<wrap-t>repeat</wrap-t>
|
||||
<internal-format>normalized</internal-format>
|
||||
</texture>
|
||||
<!--<base_layer_magnification>5.0</base_layer_magnification>
|
||||
<overlay_layer_magnification>4.0</overlay_layer_magnification>
|
||||
<grain_layer_magnification>4.0</grain_layer_magnification>
|
||||
<use_overlay>0</use_overlay>
|
||||
<use_grain>0</use_grain>
|
||||
<use_color_overlay>1</use_color_overlay>
|
||||
<grit_alpha>1.0</grit_alpha>
|
||||
<overlay_bias>0.0</overlay_bias>
|
||||
<overlay_alpha>1.0</overlay_alpha>-->
|
||||
<max_grass_height>0.3</max_grass_height>
|
||||
<grass_density>1.0</grass_density>
|
||||
<grass_groups>2</grass_groups>
|
||||
<grass_modulate_by_overlay>0</grass_modulate_by_overlay>
|
||||
<grass_modulate_height_min>0.0</grass_modulate_height_min>
|
||||
<bend-x>0</bend-x>
|
||||
<bend-y>0</bend-y>
|
||||
<windE><use>/environment/sea/surface/wind-from-east-fps</use></windE>
|
||||
<windN><use>/environment/sea/surface/wind-from-north-fps</use></windN>
|
||||
|
||||
</parameters>
|
||||
|
||||
|
@ -707,17 +675,17 @@
|
|||
<value><use>scattering</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>bend_x</name>
|
||||
<name>wind_x</name>
|
||||
<type>float</type>
|
||||
<value>
|
||||
<use>bend-x</use>
|
||||
<use>windE</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>bend_y</name>
|
||||
<uniform>
|
||||
<name>wind_y</name>
|
||||
<type>float</type>
|
||||
<value>
|
||||
<use>bend-y</use>
|
||||
<use>windN</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
|
@ -810,6 +778,11 @@
|
|||
<type>int</type>
|
||||
<value><use>display_ysize</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>wind_effects</name>
|
||||
<type>int</type>
|
||||
<value><use>wind_effects</use></value>
|
||||
</uniform>
|
||||
|
||||
<blend>
|
||||
<active>true</active>
|
||||
|
|
|
@ -13,11 +13,12 @@ uniform float max_height;
|
|||
uniform float grass_density;
|
||||
uniform float grass_modulate_height_min;
|
||||
|
||||
uniform float bend_x;
|
||||
uniform float bend_y;
|
||||
uniform float wind_x;
|
||||
uniform float wind_y;
|
||||
|
||||
uniform int grass_modulate_by_overlay;
|
||||
uniform int grass_groups;
|
||||
uniform int wind_effects;
|
||||
|
||||
uniform sampler2D colorTex;
|
||||
uniform sampler2D densityTex;
|
||||
|
@ -64,8 +65,8 @@ float bladeNoise2D(in float x, in float y, in float dDensity, in float layer, in
|
|||
float xoffset = (rand2D(vec2(integer_x, integer_y)) -0.5);
|
||||
float yoffset = (rand2D(vec2(integer_x+1.0, integer_y)) - 0.5);
|
||||
|
||||
float xbend = (rand2D(vec2(integer_x+1.0, integer_y + 1.0)) - 0.5) + bend_x;
|
||||
float ybend = (rand2D(vec2(integer_x, integer_y + 1.0)) - 0.5) + bend_y;
|
||||
float xbend = (rand2D(vec2(integer_x+1.0, integer_y + 1.0)) - 0.5);
|
||||
float ybend = (rand2D(vec2(integer_x, integer_y + 1.0)) - 0.5);
|
||||
float fraction = BLADE_FRACTION * (0.5 + 0.5 * (1.0 - smoothstep(0.5, 1.0, layer)));
|
||||
|
||||
float bend = 0.5 * layer * layer;
|
||||
|
@ -83,11 +84,30 @@ return bladeNoise2D(coord.x/wavelength, coord.y/wavelength, dDensity, layer, d_f
|
|||
|
||||
void main()
|
||||
{
|
||||
vec2 texCoord = gl_TexCoord[0].st;
|
||||
|
||||
|
||||
if (season > 1.6) {discard;}
|
||||
if (g_distance_to_eye > MAX_DISTANCE) {discard;}
|
||||
|
||||
vec2 texCoord = gl_TexCoord[0].st;
|
||||
|
||||
if (wind_effects > 1)
|
||||
{
|
||||
vec2 windDir = normalize(vec2 (max(wind_x, 0.1), wind_y) );
|
||||
float windStrength = 0.5 * length(vec2 (wind_x, wind_y));
|
||||
float windAmplitude = 1.0 + 0.3 * windStrength;
|
||||
float sineTerm = sin(0.7 * windStrength * osg_SimulationTime + 0.05 * (g_rawpos.x + g_rawpos.y));
|
||||
sineTerm = sineTerm + sin(0.6 * windStrength * osg_SimulationTime + 0.04 * (g_rawpos.x + g_rawpos.y));
|
||||
sineTerm = sineTerm + sin(0.44 * windStrength * osg_SimulationTime + 0.05 * (g_rawpos.x + g_rawpos.y));
|
||||
sineTerm = sineTerm/3.0;
|
||||
sineTerm = 5.0 * sineTerm * sineTerm;
|
||||
|
||||
float windDisplacement = pow(g_layer/32.0, 2.0) * clamp((windStrength + windAmplitude * sineTerm), -30.0, 30.0);
|
||||
|
||||
|
||||
|
||||
texCoord += (windDisplacement * windDir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue