فهرست منبع

texture name + fixed distance when no texture depth

Nicolas Cannasse 11 سال پیش
والد
کامیت
e8694eff01
2فایلهای تغییر یافته به همراه12 افزوده شده و 1 حذف شده
  1. 11 1
      h3d/pass/Distance.hx
  2. 1 0
      h3d/pass/ShadowMap.hx

+ 11 - 1
h3d/pass/Distance.hx

@@ -3,11 +3,16 @@ package h3d.pass;
 class Distance extends Base {
 
 	var texture : h3d.mat.Texture;
+	var hasTargetDepth : Bool;
+	var clear : Clear;
 
 	public function new(name) {
 		super(name);
 		priority = 10;
 		lightSystem = null;
+		hasTargetDepth = h3d.Engine.getCurrent().driver.hasFeature(TargetDepthBuffer);
+		if( !hasTargetDepth )
+			clear = new Clear();
 	}
 
 	override function getOutputs() {
@@ -17,11 +22,16 @@ class Distance extends Base {
 	override function draw(ctx : h3d.scene.RenderContext, passes) {
 		if( texture == null || texture.width != ctx.engine.width || texture.height != ctx.engine.height ) {
 			if( texture != null ) texture.dispose();
-			texture = new h3d.mat.Texture(ctx.engine.width, ctx.engine.height, [Target, TargetDepth, TargetNoFlipY]);
+			texture = new h3d.mat.Texture(ctx.engine.width, ctx.engine.height, [Target, hasTargetDepth ? TargetDepth : TargetUseDefaultDepth, TargetNoFlipY]);
+			texture.setName("distanceMap");
 		}
 		ctx.engine.setTarget(texture);
 		passes = super.draw(ctx, passes);
 		ctx.engine.setTarget(null);
+
+		if( !hasTargetDepth )
+			clear.apply(1);
+
 		return passes;
 	}
 

+ 1 - 0
h3d/pass/ShadowMap.hx

@@ -68,6 +68,7 @@ class ShadowMap extends Base {
 				blurTexture = null;
 			}
 			texture = new h3d.mat.Texture(size, size, [Target, hasTargetDepth ? TargetDepth : TargetUseDefaultDepth, TargetNoFlipY]);
+			texture.setName("shadowMap");
 		}
 		if( blur.quality > 0 && blurTexture == null )
 			blurTexture = new h3d.mat.Texture(size, size, [Target, TargetNoFlipY]);