Weiter an den Baum Systemen gearbeitet

This commit is contained in:
2026-08-23 17:21:21 +02:00
parent d65ebbfeb6
commit 46b504e050
4 changed files with 246 additions and 150 deletions

View File

@@ -16,7 +16,8 @@ out vec2 texCoord;
out vec3 worldNormal;
void main() {
float windW = inColor.r;
float windW = inColor.r; // Ast-Wind (0=Wurzel, 1=Astspitze)
float leafFlutter = inColor.g; // Blatt-Flattern (0=Ansatz, 1=Blattspitze)
float t = g_Time * m_WindSpeed;
vec4 worldPos = g_WorldMatrix * vec4(inPosition, 1.0);
@@ -30,16 +31,20 @@ void main() {
vec2 hashPos = floor(vec2(g_WorldMatrix[3][0], g_WorldMatrix[3][2]));
float randPhase = fract(sin(dot(hashPos, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
// Ast-Schwingen (niedrige Frequenz, große Amplitude)
float mainSway = sin(t + wavePhase * 0.08 + randPhase) * windW * m_WindStrength;
float crossSway = cos(t * 0.73 + wavePhase * 0.06 + randPhase) * windW * m_WindStrength * 0.25;
// Blatt-Flattern (hohe Frequenz, kleine Amplitude, unabhängig vom Ast-Wind)
float flutter = sin(t * 2.9 + wavePhase * 0.22 + randPhase * 1.6) * leafFlutter * m_WindStrength * 0.5;
// Y-Kompression: Äste neigen sich statt zu strecken → verhindert Breiterwerden der Spitzen
float sway2 = mainSway * mainSway + crossSway * crossSway;
vec3 animPos = inPosition + vec3(
windN.x * mainSway + perpN.x * crossSway,
windN.x * mainSway + perpN.x * crossSway + perpN.x * flutter,
-sway2 * 0.5,
windN.y * mainSway + perpN.y * crossSway
windN.y * mainSway + perpN.y * crossSway + perpN.y * flutter
);
gl_Position = g_WorldViewProjectionMatrix * vec4(animPos, 1.0);