Fix ground clutter height sampling and terrain shader GPU crash

- Fix HeightMap::getHeight() to use interleaved 17-wide row layout
  matching MCVT storage (was using wrong 9-wide contiguous indexing)
- Guard terrain bump mapping normalize against zero-length vectors
  to prevent NaN propagation and GPU faults
This commit is contained in:
Kelsi 2026-02-23 06:46:31 -08:00
parent 1e08d6ff22
commit 3e6de8485b
3 changed files with 10 additions and 20 deletions

View file

@ -96,7 +96,9 @@ void main() {
// Bump strength controls how much texture detail affects lighting
const float bumpStrength = 9.0;
vec3 perturbation = (dLdx * cross(norm, dpdy) + dLdy * cross(dpdx, norm)) * bumpStrength;
norm = normalize(norm - perturbation);
vec3 candidate = norm - perturbation;
float len2 = dot(candidate, candidate);
norm = (len2 > 1e-8) ? candidate * inversesqrt(len2) : norm;
}
vec3 lightDir2 = normalize(-lightDir.xyz);

Binary file not shown.