Align sun placement and shadow direction to active lighting

- drive shadow light direction from live LightingManager directionalDir
- normalize shadow light to downward-facing convention with grazing-angle guard
- make celestial/sky sun placement robust to directionalDir convention mismatches
- keep visible sun above horizon while preserving shadow alignment
This commit is contained in:
Kelsi 2026-02-21 03:21:08 -08:00
parent 566e7138f3
commit 8156942b66
3 changed files with 43 additions and 4 deletions

View file

@ -148,9 +148,13 @@ void SkySystem::render(const Camera& camera, const SkyParams& params) {
glm::vec3 SkySystem::getSunPosition(const SkyParams& params) const {
glm::vec3 dir = glm::normalize(params.directionalDir);
if (glm::length(dir) < 0.0001f) {
dir = glm::vec3(0.0f, 0.0f, 1.0f);
dir = glm::vec3(0.0f, 0.0f, -1.0f);
}
glm::vec3 pos = dir * 800.0f;
glm::vec3 sunDir = -dir;
if (sunDir.z < 0.0f) {
sunDir = dir;
}
glm::vec3 pos = sunDir * 800.0f;
return pos;
}