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

Revert "PassNode: Fix depthTexture creation when `depthBuffer: false`" (#33408)

Michael Herzog пре 3 дана
родитељ
комит
1453d4ecbb
2 измењених фајлова са 21 додато и 40 уклоњено
  1. 10 23
      src/nodes/display/PassNode.js
  2. 11 17
      src/renderers/common/Textures.js

+ 10 - 23
src/nodes/display/PassNode.js

@@ -251,22 +251,14 @@ class PassNode extends TempNode {
 		 */
 		this._height = 1;
 
+		const depthTexture = new DepthTexture();
+		depthTexture.isRenderTargetTexture = true;
+		//depthTexture.type = FloatType;
+		depthTexture.name = 'depth';
+
 		const renderTarget = new RenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: HalfFloatType, ...options, } );
 		renderTarget.texture.name = 'output';
-
-		let depthTexture = null;
-
-		if ( this.scope === PassNode.DEPTH || options.depthBuffer !== false ) {
-
-			depthTexture = new DepthTexture();
-			depthTexture.isRenderTargetTexture = true;
-			//depthTexture.type = FloatType;
-			depthTexture.name = 'depth';
-
-			renderTarget.depthTexture = depthTexture;
-
-		}
-
+		renderTarget.depthTexture = depthTexture;
 
 		/**
 		 * The pass's render target.
@@ -318,18 +310,13 @@ class PassNode extends TempNode {
 		 * A dictionary holding the internal result textures.
 		 *
 		 * @private
-		 * @type {{ output: Texture, depth?: DepthTexture }}
+		 * @type {Object<string, Texture>}
 		 */
 		this._textures = {
-			output: renderTarget.texture
+			output: renderTarget.texture,
+			depth: depthTexture
 		};
 
-		if ( depthTexture !== null ) {
-
-			this._textures.depth = depthTexture;
-
-		}
-
 		/**
 		 * A dictionary holding the internal texture nodes.
 		 *
@@ -770,7 +757,7 @@ class PassNode extends TempNode {
 
 		this.renderTarget.texture.type = renderer.getOutputBufferType();
 
-		if ( renderer.reversedDepthBuffer === true && this.renderTarget.depthTexture !== null ) {
+		if ( renderer.reversedDepthBuffer === true ) {
 
 			this.renderTarget.depthTexture.type = FloatType;
 

+ 11 - 17
src/renderers/common/Textures.js

@@ -78,30 +78,24 @@ class Textures extends DataMap {
 		const mipWidth = size.width >> activeMipmapLevel;
 		const mipHeight = size.height >> activeMipmapLevel;
 
+		let depthTexture = renderTarget.depthTexture || depthTextureMips[ activeMipmapLevel ];
 		const useDepthTexture = renderTarget.depthBuffer === true || renderTarget.stencilBuffer === true;
-		let depthTexture = null;
 
 		let textureNeedsUpdate = false;
 
-		if ( useDepthTexture ) {
+		if ( depthTexture === undefined && useDepthTexture ) {
 
-			depthTexture = renderTarget.depthTexture || depthTextureMips[ activeMipmapLevel ];
+			depthTexture = new DepthTexture();
 
-			if ( depthTexture === undefined ) {
+			depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
+			depthTexture.type = renderTarget.stencilBuffer ? UnsignedInt248Type : UnsignedIntType; // FloatType
+			depthTexture.image.width = mipWidth;
+			depthTexture.image.height = mipHeight;
+			depthTexture.image.depth = size.depth;
+			depthTexture.renderTarget = renderTarget;
+			depthTexture.isArrayTexture = renderTarget.multiview === true && size.depth > 1;
 
-				depthTexture = new DepthTexture();
-
-				depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
-				depthTexture.type = renderTarget.stencilBuffer ? UnsignedInt248Type : UnsignedIntType; // FloatType
-				depthTexture.image.width = mipWidth;
-				depthTexture.image.height = mipHeight;
-				depthTexture.image.depth = size.depth;
-				depthTexture.renderTarget = renderTarget;
-				depthTexture.isArrayTexture = renderTarget.multiview === true && size.depth > 1;
-
-				depthTextureMips[ activeMipmapLevel ] = depthTexture;
-
-			}
+			depthTextureMips[ activeMipmapLevel ] = depthTexture;
 
 		}
 

粤ICP备19079148号