Преглед изворни кода

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) )
 		if( !filterPasses(passes) )
 			return;
 			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 ) {
 		if( mode != Mixed || ctx.computingStatic ) {
 			var ct = ctx.camera.target;
 			var ct = ctx.camera.target;
 			var slight = light == null ? ctx.lightSystem.shadowLight : light;
 			var slight = light == null ? ctx.lightSystem.shadowLight : light;
@@ -329,8 +321,14 @@ class DirShadowMap extends Shadows {
 			lightCamera.target.z += ct.z;
 			lightCamera.target.z += ct.z;
 			lightCamera.pos.load(ct);
 			lightCamera.pos.load(ct);
 			lightCamera.update();
 			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);
 		var texture = ctx.textures.allocTarget("dirShadowMap", size, size, false, format);
 		if( customDepth && (depth == null || depth.width != size || depth.height != size || depth.isDisposed()) ) {
 		if( customDepth && (depth == null || depth.width != size || depth.height != size || depth.isDisposed()) ) {
 			if( depth != null ) depth.dispose();
 			if( depth != null ) depth.dispose();