Skip to content

Commit

Permalink
Added shadowCameraNearFar to directional shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardodoria committed Dec 3, 2024
1 parent eb6ea2a commit 081851c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions engine/core/subsystem/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2247,11 +2247,13 @@ void RenderSystem::updateLightFromScene(LightComponent& light, Transform& transf

viewMatrix = Matrix4::lookAtMatrix(transform.worldPosition, light.worldDirection + transform.worldPosition, up);

configureLightShadowNearFar(light, camera);

//TODO: light directional cascades is only considering main camera
if (camera.type == CameraType::CAMERA_PERSPECTIVE) {

float zFar = camera.farClip;
float zNear = camera.nearClip;
float zNear = light.shadowCameraNearFar.x;
float zFar = light.shadowCameraNearFar.y;
float fov = 0;
float ratio = 1;

Expand Down Expand Up @@ -2329,8 +2331,6 @@ void RenderSystem::updateLightFromScene(LightComponent& light, Transform& transf
Matrix4 projectionMatrix;
Matrix4 viewMatrix;

configureLightShadowNearFar(light, camera);

viewMatrix = Matrix4::lookAtMatrix(transform.worldPosition, light.worldDirection + transform.worldPosition, up);

projectionMatrix = Matrix4::perspectiveMatrix(acos(light.outerConeCos)*2, 1, light.shadowCameraNearFar.x, light.shadowCameraNearFar.y);
Expand All @@ -2345,8 +2345,6 @@ void RenderSystem::updateLightFromScene(LightComponent& light, Transform& transf
Matrix4 projectionMatrix;
Matrix4 viewMatrix[6];

configureLightShadowNearFar(light, camera);

viewMatrix[0] = Matrix4::lookAtMatrix(transform.worldPosition, Vector3( 1.f, 0.f, 0.f) + transform.worldPosition, Vector3(0.f, -1.f, 0.f));
viewMatrix[1] = Matrix4::lookAtMatrix(transform.worldPosition, Vector3(-1.f, 0.f, 0.f) + transform.worldPosition, Vector3(0.f, -1.f, 0.f));
viewMatrix[2] = Matrix4::lookAtMatrix(transform.worldPosition, Vector3( 0.f, 1.f, 0.f) + transform.worldPosition, Vector3(0.f, 0.f, 1.f));
Expand Down

0 comments on commit 081851c

Please sign in to comment.