Weiter an den Dialogen gearbeitet
This commit is contained in:
@@ -4,6 +4,7 @@ uniform float g_Time;
|
||||
|
||||
uniform float m_WindSpeed;
|
||||
uniform float m_WindStrength;
|
||||
uniform vec2 m_WindDir; // normierter XZ-Windvektor
|
||||
|
||||
in vec3 inPosition;
|
||||
in vec3 inNormal;
|
||||
@@ -18,22 +19,28 @@ void main() {
|
||||
float wf = inTexCoord.x;
|
||||
|
||||
if (wf > 0.001) {
|
||||
// Weltposition als Phasenbasis → jeder Halm schwingt anders
|
||||
vec2 worldXZ = (g_WorldMatrix * pos).xz;
|
||||
float t = g_Time * m_WindSpeed;
|
||||
|
||||
float sway = sin(t * 2.1 + worldXZ.x * 0.08 + worldXZ.y * 0.06) * 0.6
|
||||
+ sin(t * 1.4 - worldXZ.x * 0.05 + worldXZ.y * 0.09) * 0.4;
|
||||
// Windrichtung (Fallback: Süd)
|
||||
vec2 windN = (dot(m_WindDir, m_WindDir) > 0.001) ? normalize(m_WindDir) : vec2(0.0, 1.0);
|
||||
|
||||
// Wellenfront: Position entlang der Windachse → Halme in Windrichtung erreicht der Impuls später
|
||||
float wavePhase = dot(worldXZ, windN);
|
||||
|
||||
// Zufälliger Phasenversatz pro Halm (Spatial-Hash → kein synchrones Schwingen)
|
||||
float randPhase = fract(sin(dot(worldXZ, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
|
||||
|
||||
float sway = sin(t * 2.1 + wavePhase * 0.10 + randPhase) * 0.6
|
||||
+ sin(t * 1.4 + wavePhase * 0.06 + randPhase * 0.73) * 0.4;
|
||||
|
||||
// Quadratische Gewichtung: Spitze biegt sich mehr als Basis
|
||||
float bend = sway * m_WindStrength * wf * wf;
|
||||
pos.x += bend;
|
||||
pos.z += bend * 0.3;
|
||||
pos.x += windN.x * bend;
|
||||
pos.z += windN.y * bend;
|
||||
}
|
||||
|
||||
varColor = inColor;
|
||||
// Normal in Weltkoordinaten (WorldMatrix ist für Gras typischerweise Identität)
|
||||
varNormal = normalize(mat3(g_WorldMatrix) * inNormal);
|
||||
|
||||
gl_Position = g_WorldViewProjectionMatrix * pos;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user