@@ -2247,11 +2247,13 @@ void RenderSystem::updateLightFromScene(LightComponent& light, Transform& transf
22472247
22482248 viewMatrix = Matrix4::lookAtMatrix (transform.worldPosition , light.worldDirection + transform.worldPosition , up);
22492249
2250+ configureLightShadowNearFar (light, camera);
2251+
22502252 // TODO: light directional cascades is only considering main camera
22512253 if (camera.type == CameraType::CAMERA_PERSPECTIVE) {
22522254
2253- float zFar = camera. farClip ;
2254- float zNear = camera. nearClip ;
2255+ float zNear = light. shadowCameraNearFar . x ;
2256+ float zFar = light. shadowCameraNearFar . y ;
22552257 float fov = 0 ;
22562258 float ratio = 1 ;
22572259
@@ -2329,8 +2331,6 @@ void RenderSystem::updateLightFromScene(LightComponent& light, Transform& transf
23292331 Matrix4 projectionMatrix;
23302332 Matrix4 viewMatrix;
23312333
2332- configureLightShadowNearFar (light, camera);
2333-
23342334 viewMatrix = Matrix4::lookAtMatrix (transform.worldPosition , light.worldDirection + transform.worldPosition , up);
23352335
23362336 projectionMatrix = Matrix4::perspectiveMatrix (acos (light.outerConeCos )*2 , 1 , light.shadowCameraNearFar .x , light.shadowCameraNearFar .y );
@@ -2345,8 +2345,6 @@ void RenderSystem::updateLightFromScene(LightComponent& light, Transform& transf
23452345 Matrix4 projectionMatrix;
23462346 Matrix4 viewMatrix[6 ];
23472347
2348- configureLightShadowNearFar (light, camera);
2349-
23502348 viewMatrix[0 ] = Matrix4::lookAtMatrix (transform.worldPosition , Vector3 ( 1 .f , 0 .f , 0 .f ) + transform.worldPosition , Vector3 (0 .f , -1 .f , 0 .f ));
23512349 viewMatrix[1 ] = Matrix4::lookAtMatrix (transform.worldPosition , Vector3 (-1 .f , 0 .f , 0 .f ) + transform.worldPosition , Vector3 (0 .f , -1 .f , 0 .f ));
23522350 viewMatrix[2 ] = Matrix4::lookAtMatrix (transform.worldPosition , Vector3 ( 0 .f , 1 .f , 0 .f ) + transform.worldPosition , Vector3 (0 .f , 0 .f , 1 .f ));
0 commit comments