Ver Fonte

Avoid velocity target allocation if not needed

TothBenoit há 1 ano atrás
pai
commit
b03fb7c55b
1 ficheiros alterados com 7 adições e 3 exclusões
  1. 7 3
      h3d/scene/pbr/Renderer.hx

+ 7 - 3
h3d/scene/pbr/Renderer.hx

@@ -471,7 +471,8 @@ class Renderer extends h3d.scene.Renderer {
 		textures.depth = allocTarget("depth", true, 1., R32F);
 		textures.hdr = allocTarget("hdrOutput", true, 1, #if MRT_low RGB10A2 #else RGBA16F #end);
 		textures.ldr = allocTarget("ldrOutput");
-		textures.velocity = allocTarget("velocity", true, 1., RG16F );
+		if ( ctx.computeVelocity )
+			textures.velocity = allocTarget("velocity", true, 1., RG16F );
 	}
 
 	public function getPbrDepth() {
@@ -607,9 +608,12 @@ class Renderer extends h3d.scene.Renderer {
 	}
 
 	function getPbrRenderTargets( depth : Bool ) {
+		var targets = [textures.albedo, textures.normal, textures.pbr #if !MRT_low , textures.other #end];
 		if ( depth )
-			return [textures.albedo, textures.normal, textures.pbr #if !MRT_low , textures.other #end, getPbrDepth(), textures.velocity];
-		return [textures.albedo, textures.normal, textures.pbr #if !MRT_low , textures.other #end, textures.velocity];
+			targets.push(getPbrDepth());
+		if ( ctx.computeVelocity )
+			targets.push(textures.velocity);
+		return targets;
 	}
 
 	override function render() {