Browse Source

Add clear and clearF for PointShadowMap

ShiroSmith 5 years ago
parent
commit
395d9f1d08
1 changed files with 11 additions and 7 deletions
  1. 11 7
      h3d/pass/PointShadowMap.hx

+ 11 - 7
h3d/pass/PointShadowMap.hx

@@ -160,13 +160,18 @@ class PointShadowMap extends Shadows {
 		if( tmpTex != null) return tmpTex;
 		tmpTex = new h3d.mat.Texture(1,1, [Target,Cube], format);
 		tmpTex.name = "defaultCubeShadowMap";
+		clear(tmpTex);
+		return tmpTex;
+	}
+
+	inline function clear( t : h3d.mat.Texture, ?layer = -1 ) {
 		if( format == RGBA )
-			tmpTex.clear(0xFFFFFF);
+			t.clear(0xFFFFFF, layer);
 		else
-			tmpTex.clearF(1);
-		return tmpTex;
+			t.clearF(1, 1, 1, 1, layer);
 	}
 
+	var clearDepthColor = new h3d.Vector(1,1,1,1);
 	override function draw( passes : h3d.pass.PassList, ?sort ) {
 		if( !enabled )
 			return;
@@ -204,7 +209,7 @@ class PointShadowMap extends Shadows {
 
 			// Shadows on the current face is disabled
 			if( !faceMask.has(CubeFaceFlag.createByIndex(i)) ) {
-				texture.clear(0xFFFFFF, 0, i);
+				clear(texture, i);
 				continue;
 			}
 
@@ -215,13 +220,12 @@ class PointShadowMap extends Shadows {
 			cullPasses(passes, function(col) return col.inFrustum(lightCamera.frustum));
 			if( passes.isEmpty() ) {
 				passes.load(save);
-				texture.clear(0xFFFFFF, 0, i);
+				clear(texture, i);
 				continue;
 			}
 
 			ctx.engine.pushTarget(texture, i);
-			ctx.engine.clear(0xFFFFFF, 1);
-
+			format == RGBA ? ctx.engine.clear(0xFFFFFF, i) : ctx.engine.clearF(clearDepthColor, 1);
 			super.draw(passes,sort);
 			passes.load(save);
 			ctx.engine.popTarget();