diff --git a/data/shaders/grass_pass.vert b/data/shaders/grass_pass.vert index 23daa553c..e6903c19e 100644 --- a/data/shaders/grass_pass.vert +++ b/data/shaders/grass_pass.vert @@ -20,13 +20,16 @@ out vec2 uv; void main() { + vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5; + test += cos(windDir) * 0.7; + mat4 new_model_matrix = ModelMatrix; mat4 new_inverse_model_matrix = InverseModelMatrix; - new_model_matrix[3].xyz += windDir * Color.r; + new_model_matrix[3].xyz += test * Color.r; // FIXME doesn't seem to make too much difference in pass 2, because this // affects "nor" which is later only * 0.1 by scattering - new_inverse_model_matrix[3].xyz -= windDir * Color.r; + new_inverse_model_matrix[3].xyz -= test * Color.r; mat4 ModelViewProjectionMatrix = ProjectionViewMatrix * new_model_matrix; mat4 TransposeInverseModelView = transpose(InverseViewMatrix * new_inverse_model_matrix); diff --git a/data/shaders/instanced_grass.vert b/data/shaders/instanced_grass.vert index 57adee847..0127a8346 100644 --- a/data/shaders/instanced_grass.vert +++ b/data/shaders/instanced_grass.vert @@ -41,8 +41,10 @@ flat out sampler2D thirdhandle; void main() { - mat4 ModelMatrix = getWorldMatrix(Origin + windDir * Color.r, Orientation, Scale); - mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + windDir * Color.r, Orientation, Scale) * InverseViewMatrix); + vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5; + test += cos(windDir) * 0.7; + mat4 ModelMatrix = getWorldMatrix(Origin + test * Color.r, Orientation, Scale); + mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + test * Color.r, Orientation, Scale) * InverseViewMatrix); gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.); nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz; uv = Texcoord; diff --git a/data/shaders/instanced_grassshadow.vert b/data/shaders/instanced_grassshadow.vert index 5d5e8e6e2..a31d49d92 100644 --- a/data/shaders/instanced_grassshadow.vert +++ b/data/shaders/instanced_grassshadow.vert @@ -40,17 +40,20 @@ flat out uvec2 hdle; void main(void) { + + vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5; + test += cos(windDir) * 0.7; mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale); #ifdef VSLayer gl_Layer = layer; - gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.); + gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.); uv = Texcoord; #ifdef Use_Bindless_Texture handle = Handle; #endif #else layerId = layer; - gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.); + gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.); tc = Texcoord; #ifdef Use_Bindless_Texture hdle = Handle; diff --git a/data/shaders/shadow_grass.vert b/data/shaders/shadow_grass.vert index 95827b872..bb978f921 100644 --- a/data/shaders/shadow_grass.vert +++ b/data/shaders/shadow_grass.vert @@ -21,13 +21,17 @@ out int layerId; void main(void) { + + vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5; + test += cos(windDir) * 0.7; + #ifdef VSLayer gl_Layer = layer; uv = Texcoord; - gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + windDir * Color.r, 1.); + gl_Position = ShadowViewProjMatrixes[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.); #else layerId = layer; tc = Texcoord; - gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + windDir * Color.r, 1.); + gl_Position = ShadowViewProjMatrixes[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.); #endif } diff --git a/src/graphics/stk_mesh.cpp b/src/graphics/stk_mesh.cpp index 397dd8b77..87e2e2b29 100644 --- a/src/graphics/stk_mesh.cpp +++ b/src/graphics/stk_mesh.cpp @@ -337,7 +337,7 @@ core::vector3df getWindDir() const float time = irr_driver->getDevice()->getTimer()->getTime() / 1000.0f; GrassShaderProvider *gsp = (GrassShaderProvider *)Shaders::getCallback(ES_GRASS); - return (gsp->getSpeed() * cos(time)) * vector3df(1., 0., 0.); + return (gsp->getSpeed() * time * vector3df(1., 0., 0.)); } // getWindDir // ----------------------------------------------------------------------------