From 07d62eaa01545e35d0c928ddf1202d439d61891f Mon Sep 17 00:00:00 2001 From: Cody Glassman Date: Mon, 10 Mar 2025 10:13:35 -0700 Subject: [PATCH] tweak leaf motion --- files/shaders/lib/nature/leaves.glsl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/files/shaders/lib/nature/leaves.glsl b/files/shaders/lib/nature/leaves.glsl index c8d75e9300..37ab9176d4 100644 --- a/files/shaders/lib/nature/leaves.glsl +++ b/files/shaders/lib/nature/leaves.glsl @@ -21,13 +21,14 @@ vec4 transformLeafVertex(LeafParams params, vec4 position, vec4 color, vec3 norm if (amplitude <= 0.f) return position; - const vec2 axisFrequencyFactor = vec2(0.1, 0.25); - float gust = 0.5 * sin(0.15 * osg_SimulationTime * 6.136 + params.mTimeOffset) + 0.5; - float wind = sin(osg_SimulationTime * 10.0 + params.mTimeOffset) * windSpeed * gust; + float offset = params.mTimeOffset + position.x * 0.1 + position.y * 0.1; + float period = 0.5 * sin(0.15 * osg_SimulationTime * 6.136 + params.mTimeOffset) + 0.5; + float wind = sin(osg_SimulationTime * params.mLeafFrequency + offset) * params.mLeafAmplitude * windSpeed * period; float spatialOffset = dot(position.xyz, vec3(1.0)); - vec2 phase = fract(axisFrequencyFactor * (wind * params.mLeafFrequency) + spatialOffset + 0.5); - vec2 leafMotion = smoothstep(0.0, 1.0, abs(2.0 * phase - 1.0)) * 10.0; + const vec2 axisFrequencyFactor = vec2(0.1, 0.25); + vec2 phase = fract(axisFrequencyFactor * (wind * params.mLeafFrequency * 10) + spatialOffset + 0.5); + vec2 leafMotion = smoothstep(0.0, 1.0, abs(2.0 * phase - 1.0)); float normalMultiplier = (leafMotion.x + 0.1 * leafMotion.y) * amplitude; position.xyz += normal.xyz * normalMultiplier;