1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Fix downward shadows at time 12000 (#16326)

This commit is contained in:
Lucas OH 2025-07-12 13:23:17 +02:00 committed by GitHub
parent 4f42b4308c
commit f71e1447c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -303,12 +303,14 @@ public:
CMatrix4<T> &buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true); CMatrix4<T> &buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true);
//! Builds a left-handed look-at matrix. //! Builds a left-handed look-at matrix.
//! NOTE: upVector must not be collinear to the postion-to-target vector
CMatrix4<T> &buildCameraLookAtMatrixLH( CMatrix4<T> &buildCameraLookAtMatrixLH(
const vector3df &position, const vector3df &position,
const vector3df &target, const vector3df &target,
const vector3df &upVector); const vector3df &upVector);
//! Builds a right-handed look-at matrix. //! Builds a right-handed look-at matrix.
//! NOTE: upVector must not be collinear to the postion-to-target vector
CMatrix4<T> &buildCameraLookAtMatrixRH( CMatrix4<T> &buildCameraLookAtMatrixRH(
const vector3df &position, const vector3df &position,
const vector3df &target, const vector3df &target,

View file

@ -68,11 +68,17 @@ void DirectionalLight::createSplitMatrices(const Camera *cam)
// we must compute the viewmat with the position - the camera offset // we must compute the viewmat with the position - the camera offset
// but the future_frustum position must be the actual world position // but the future_frustum position must be the actual world position
v3f eye = center_scene - eye_displacement; v3f eye = center_scene - eye_displacement;
v3f up(0.0f, 1.0f, 0.0f);
// eye_displacement and up shall not be collinear
// At noon, light points straight down, the "up" vector can be anything
// that is not along the up axis
if (core::equals(eye_displacement.crossProduct(up).getLengthSQ(), 0.f))
up = v3f(1.0f, 0.0f, 0.0f);
future_frustum.player = cam_pos_scene; future_frustum.player = cam_pos_scene;
future_frustum.position = center_world - eye_displacement; future_frustum.position = center_world - eye_displacement;
future_frustum.length = length; future_frustum.length = length;
future_frustum.radius = radius; future_frustum.radius = radius;
future_frustum.ViewMat.buildCameraLookAtMatrixLH(eye, center_scene, v3f(0.0f, 1.0f, 0.0f)); future_frustum.ViewMat.buildCameraLookAtMatrixLH(eye, center_scene, up);
future_frustum.ProjOrthMat.buildProjectionMatrixOrthoLH(radius, radius, future_frustum.ProjOrthMat.buildProjectionMatrixOrthoLH(radius, radius,
0.0f, length, false); 0.0f, length, false);
} }