mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Fix downward shadows at time 12000 (#16326)
This commit is contained in:
@@ -303,12 +303,14 @@ public:
|
||||
CMatrix4<T> &buildProjectionMatrixOrthoRH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar, bool zClipFromZero = true);
|
||||
|
||||
//! Builds a left-handed look-at matrix.
|
||||
//! NOTE: upVector must not be collinear to the postion-to-target vector
|
||||
CMatrix4<T> &buildCameraLookAtMatrixLH(
|
||||
const vector3df &position,
|
||||
const vector3df &target,
|
||||
const vector3df &upVector);
|
||||
|
||||
//! Builds a right-handed look-at matrix.
|
||||
//! NOTE: upVector must not be collinear to the postion-to-target vector
|
||||
CMatrix4<T> &buildCameraLookAtMatrixRH(
|
||||
const vector3df &position,
|
||||
const vector3df &target,
|
||||
|
@@ -68,11 +68,17 @@ void DirectionalLight::createSplitMatrices(const Camera *cam)
|
||||
// we must compute the viewmat with the position - the camera offset
|
||||
// but the future_frustum position must be the actual world position
|
||||
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.position = center_world - eye_displacement;
|
||||
future_frustum.length = length;
|
||||
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,
|
||||
0.0f, length, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user