瀏覽代碼

Fix dynamic dir shadow map when moving camera.

clandrin 2 年之前
父節點
當前提交
e2018b78ca
共有 1 個文件被更改,包括 6 次插入8 次删除
  1. 6 8
      h3d/pass/DirShadowMap.hx

+ 6 - 8
h3d/pass/DirShadowMap.hx

@@ -306,14 +306,6 @@ class DirShadowMap extends Shadows {
 		if( !filterPasses(passes) )
 			return;
 
-		if( mode != Mixed || ctx.computingStatic ) {
-			lightCamera.orthoBounds.empty();
-			if( !passes.isEmpty() ) calcShadowBounds(lightCamera);
-			lightCamera.update();
-		}
-
-		cullPasses(passes,function(col) return col.inFrustum(lightCamera.frustum));
-
 		if( mode != Mixed || ctx.computingStatic ) {
 			var ct = ctx.camera.target;
 			var slight = light == null ? ctx.lightSystem.shadowLight : light;
@@ -329,8 +321,14 @@ class DirShadowMap extends Shadows {
 			lightCamera.target.z += ct.z;
 			lightCamera.pos.load(ct);
 			lightCamera.update();
+
+			lightCamera.orthoBounds.empty();
+			if( !passes.isEmpty() ) calcShadowBounds(lightCamera);
+			lightCamera.update();
 		}
 
+		cullPasses(passes,function(col) return col.inFrustum(lightCamera.frustum));
+
 		var texture = ctx.textures.allocTarget("dirShadowMap", size, size, false, format);
 		if( customDepth && (depth == null || depth.width != size || depth.height != size || depth.isDisposed()) ) {
 			if( depth != null ) depth.dispose();