Bugfixes, weitere Vegetationsgeneratoren hinzugefügt

This commit is contained in:
2026-07-25 20:16:13 +02:00
parent 574bad3d67
commit d7aeb890c9
66 changed files with 2379 additions and 173 deletions

View File

@@ -25,14 +25,20 @@ void main() {
vec2 windN = (dot(m_WindDir, m_WindDir) > 0.001) ? normalize(m_WindDir) : vec2(0.0, 1.0);
vec2 perpN = vec2(-windN.y, windN.x);
float wavePhase = dot(worldXZ, windN);
float randPhase = fract(sin(dot(worldXZ, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
// 1m-Raster für den Phase-Hash: benachbarte Vertices (Ast + Blatt-Basis) landen im
// gleichen Rasterfeld → identische randPhase → Blatt-Basis schwebt nicht mehr
vec2 hashPos = floor(worldXZ);
float randPhase = fract(sin(dot(hashPos, vec2(127.1, 311.7))) * 43758.5453) * 6.2832;
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;
// 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,
0.0,
-sway2 * 0.5,
windN.y * mainSway + perpN.y * crossSway
);

View File

@@ -1,5 +1,12 @@
uniform sampler2D m_TexFlat;
uniform sampler2D m_TexSteep;
#ifdef HAS_SPLAT
uniform sampler2D m_SplatMap;
uniform sampler2D m_TexFlat2;
uniform sampler2D m_TexFlat3;
uniform sampler2D m_TexFlat4;
#endif
uniform float m_TexScale;
#ifdef HAS_NM_FLAT
@@ -57,7 +64,22 @@ void main() {
// Flat: reines XZ-UV wie das Terrain (uvY = worldPos.xz / texScale), kein Triplanar.
// Steep: Triplanar für alle nicht-flachen Flächen inkl. Decken und Tunnelwände.
vec4 col = texture(m_TexFlat, uvY) * flatBlend
#ifdef HAS_SPLAT
// Splatmap-UV: worldPos.xz linear auf [0,1] (kein Flip nötig Konvention im Editor: pz=0 → worldZ=-2048)
vec2 splatUV = (vWorldPos.xz + 2048.0) / 4096.0;
vec4 splat = texture(m_SplatMap, splatUV);
float w2 = splat.g;
float w3 = splat.b;
float w4 = splat.a;
float w1 = max(0.0, 1.0 - w2 - w3 - w4);
vec4 flatCol = texture(m_TexFlat, uvY) * w1
+ texture(m_TexFlat2, uvY) * w2
+ texture(m_TexFlat3, uvY) * w3
+ texture(m_TexFlat4, uvY) * w4;
#else
vec4 flatCol = texture(m_TexFlat, uvY);
#endif
vec4 col = flatCol * flatBlend
+ triplanar(m_TexSteep, uvX, uvY, uvZ, bw) * steepBlend;
// Geometrie-Normale für Beleuchtung, ggf. durch Normal-Map ersetzt.