Skip to content

Commit 1453d4e

Browse files
authored
Revert "PassNode: Fix depthTexture creation when depthBuffer: false" (#33408)
1 parent 3c084b0 commit 1453d4e

2 files changed

Lines changed: 21 additions & 40 deletions

File tree

src/nodes/display/PassNode.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,14 @@ class PassNode extends TempNode {
251251
*/
252252
this._height = 1;
253253

254+
const depthTexture = new DepthTexture();
255+
depthTexture.isRenderTargetTexture = true;
256+
//depthTexture.type = FloatType;
257+
depthTexture.name = 'depth';
258+
254259
const renderTarget = new RenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: HalfFloatType, ...options, } );
255260
renderTarget.texture.name = 'output';
256-
257-
let depthTexture = null;
258-
259-
if ( this.scope === PassNode.DEPTH || options.depthBuffer !== false ) {
260-
261-
depthTexture = new DepthTexture();
262-
depthTexture.isRenderTargetTexture = true;
263-
//depthTexture.type = FloatType;
264-
depthTexture.name = 'depth';
265-
266-
renderTarget.depthTexture = depthTexture;
267-
268-
}
269-
261+
renderTarget.depthTexture = depthTexture;
270262

271263
/**
272264
* The pass's render target.
@@ -318,18 +310,13 @@ class PassNode extends TempNode {
318310
* A dictionary holding the internal result textures.
319311
*
320312
* @private
321-
* @type {{ output: Texture, depth?: DepthTexture }}
313+
* @type {Object<string, Texture>}
322314
*/
323315
this._textures = {
324-
output: renderTarget.texture
316+
output: renderTarget.texture,
317+
depth: depthTexture
325318
};
326319

327-
if ( depthTexture !== null ) {
328-
329-
this._textures.depth = depthTexture;
330-
331-
}
332-
333320
/**
334321
* A dictionary holding the internal texture nodes.
335322
*
@@ -770,7 +757,7 @@ class PassNode extends TempNode {
770757

771758
this.renderTarget.texture.type = renderer.getOutputBufferType();
772759

773-
if ( renderer.reversedDepthBuffer === true && this.renderTarget.depthTexture !== null ) {
760+
if ( renderer.reversedDepthBuffer === true ) {
774761

775762
this.renderTarget.depthTexture.type = FloatType;
776763

src/renderers/common/Textures.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,24 @@ class Textures extends DataMap {
7878
const mipWidth = size.width >> activeMipmapLevel;
7979
const mipHeight = size.height >> activeMipmapLevel;
8080

81+
let depthTexture = renderTarget.depthTexture || depthTextureMips[ activeMipmapLevel ];
8182
const useDepthTexture = renderTarget.depthBuffer === true || renderTarget.stencilBuffer === true;
82-
let depthTexture = null;
8383

8484
let textureNeedsUpdate = false;
8585

86-
if ( useDepthTexture ) {
86+
if ( depthTexture === undefined && useDepthTexture ) {
8787

88-
depthTexture = renderTarget.depthTexture || depthTextureMips[ activeMipmapLevel ];
88+
depthTexture = new DepthTexture();
8989

90-
if ( depthTexture === undefined ) {
90+
depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
91+
depthTexture.type = renderTarget.stencilBuffer ? UnsignedInt248Type : UnsignedIntType; // FloatType
92+
depthTexture.image.width = mipWidth;
93+
depthTexture.image.height = mipHeight;
94+
depthTexture.image.depth = size.depth;
95+
depthTexture.renderTarget = renderTarget;
96+
depthTexture.isArrayTexture = renderTarget.multiview === true && size.depth > 1;
9197

92-
depthTexture = new DepthTexture();
93-
94-
depthTexture.format = renderTarget.stencilBuffer ? DepthStencilFormat : DepthFormat;
95-
depthTexture.type = renderTarget.stencilBuffer ? UnsignedInt248Type : UnsignedIntType; // FloatType
96-
depthTexture.image.width = mipWidth;
97-
depthTexture.image.height = mipHeight;
98-
depthTexture.image.depth = size.depth;
99-
depthTexture.renderTarget = renderTarget;
100-
depthTexture.isArrayTexture = renderTarget.multiview === true && size.depth > 1;
101-
102-
depthTextureMips[ activeMipmapLevel ] = depthTexture;
103-
104-
}
98+
depthTextureMips[ activeMipmapLevel ] = depthTexture;
10599

106100
}
107101

0 commit comments

Comments
 (0)