Improved wind effect for vegetation
This commit is contained in:
parent
b8e3de0161
commit
97670ed23c
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user