1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-14 01:19:59 +00:00

Merge branch 'tree_anim' into 'master'

Draft: Tree animation

See merge request OpenMW/openmw!3094
This commit is contained in:
Petr Mikheev 2025-03-13 02:16:52 +00:00
commit e51f6a72d2

View File

@ -31,6 +31,10 @@ varying float linearDepth;
varying vec3 passViewPos;
varying vec3 passNormal;
uniform bool useTreeAnim;
uniform float osg_SimulationTime;
#define WIND_AMPLITUDE 0.5
#include "lib/light/lighting.glsl"
#include "lib/view/depth.glsl"
@ -40,9 +44,15 @@ varying vec3 passNormal;
void main(void)
{
gl_Position = modelToClip(gl_Vertex);
vec4 modelPos = gl_Vertex;
if (useTreeAnim) {
modelPos.xyz += sin(osg_SimulationTime * (WIND_AMPLITUDE + 1.0) * 1.5 + gl_Vertex.yzx * 0.01)
* 0.01 * WIND_AMPLITUDE * gl_Color.a * gl_Vertex.z;
}
vec4 viewPos = modelToView(gl_Vertex);
gl_Position = modelToClip(modelPos);
vec4 viewPos = modelToView(modelPos);
gl_ClipVertex = viewPos;
euclideanDepth = length(viewPos.xyz);
linearDepth = getLinearDepth(gl_Position.z, viewPos.z);