1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Use Sky class to obtain directional light source position for shadows (#12662)

* Also remove unused Sky::getSkyBodyOrbitTilt method

Fixes misalignment of sun position and shadow direction at high tilt values.
This commit is contained in:
x2048 2022-08-17 16:30:05 +02:00 committed by GitHub
parent 3f67215df9
commit 8c29c4f620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View file

@ -4065,10 +4065,7 @@ void Game::updateShadows()
timeoftheday = fmod(timeoftheday + 0.75f, 0.5f) + 0.25f;
const float offset_constant = 10000.0f;
v3f light(0.0f, 0.0f, -1.0f);
light.rotateXZBy(90);
light.rotateXYBy(timeoftheday * 360 - 90);
light.rotateYZBy(sky->getSkyBodyOrbitTilt());
v3f light = is_day ? sky->getSunDirection() : sky->getMoonDirection();
v3f sun_pos = light * offset_constant;