c4a8e9b098
* Vegetation shader and technique bugfixes * GLSL bug fix for vegetation shader * pivot fixed * Shaders fixed * Text formatting
33 lines
924 B
GLSL
33 lines
924 B
GLSL
#include "Uniforms.glsl"
|
|
#include "Transform.glsl"
|
|
|
|
uniform float cWindHeightFactor;
|
|
uniform float cWindHeightPivot;
|
|
uniform float cWindPeriod;
|
|
uniform vec2 cWindWorldSpacing;
|
|
#ifdef WINDSTEMAXIS
|
|
uniform vec3 cWindStemAxis;
|
|
#endif
|
|
|
|
varying vec3 vTexCoord;
|
|
|
|
void VS()
|
|
{
|
|
mat4 modelMatrix = iModelMatrix;
|
|
vec3 worldPos = GetWorldPos(modelMatrix);
|
|
|
|
#ifdef WINDSTEMAXIS
|
|
float stemDistance = dot(iPos.xyz, cWindStemAxis);
|
|
#else
|
|
float stemDistance = iPos.y;
|
|
#endif
|
|
float windStrength = max(stemDistance - cWindHeightPivot, 0.0) * cWindHeightFactor;
|
|
float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
|
|
worldPos.x += windStrength * sin(windPeriod);
|
|
worldPos.z -= windStrength * cos(windPeriod);
|
|
|
|
gl_Position = GetClipPos(worldPos);
|
|
vTexCoord = vec3(GetTexCoord(iTexCoord), GetDepth(gl_Position));
|
|
}
|
|
|