浏览代码

Improve default behavior of CSM.

clementlandrin 2 年之前
父节点
当前提交
abbeda22cf
共有 1 个文件被更改,包括 4 次插入6 次删除
  1. 4 6
      h3d/pass/CascadeShadowMap.hx

+ 4 - 6
h3d/pass/CascadeShadowMap.hx

@@ -159,12 +159,10 @@ class CascadeShadowMap extends DirShadowMap {
 			lightCamera.orthoBounds.empty();
 			for ( lC in lightCameras ) lC.orthoBounds.empty();
 			if( !passes.isEmpty() ) calcShadowBounds(lightCamera);
-			if ( castingMaxDist > 0.0 ) {
-				var pt = ctx.camera.pos.clone();
-				pt.transform(lightCamera.mcam);
-				lightCamera.orthoBounds.zMax = pt.z + castingMaxDist; 
-				lightCamera.orthoBounds.zMin = pt.z - castingMaxDist;
-			} 
+			var pt = ctx.camera.pos.clone();
+			pt.transform(lightCamera.mcam);
+			lightCamera.orthoBounds.zMax = pt.z + (castingMaxDist > 0.0 ? castingMaxDist : maxDist < 0.0 ? ctx.camera.zFar : maxDist); 
+			lightCamera.orthoBounds.zMin = pt.z - (castingMaxDist > 0.0 ? castingMaxDist : maxDist < 0.0 ? ctx.camera.zFar : maxDist);
 			lightCamera.update();
 		}