Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions src/nodes/display/PassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,22 @@ 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';
renderTarget.depthTexture = depthTexture;

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;

}


/**
* The pass's render target.
Expand Down Expand Up @@ -310,13 +318,18 @@ class PassNode extends TempNode {
* A dictionary holding the internal result textures.
*
* @private
* @type {Object<string, Texture>}
* @type {{ output: Texture, depth?: DepthTexture }}
*/
this._textures = {
output: renderTarget.texture,
depth: depthTexture
output: renderTarget.texture
};

if ( depthTexture !== null ) {

this._textures.depth = depthTexture;

}

/**
* A dictionary holding the internal texture nodes.
*
Expand Down Expand Up @@ -757,7 +770,7 @@ class PassNode extends TempNode {

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

if ( renderer.reversedDepthBuffer === true ) {
if ( renderer.reversedDepthBuffer === true && this.renderTarget.depthTexture !== null ) {

this.renderTarget.depthTexture.type = FloatType;

Expand Down
28 changes: 17 additions & 11 deletions src/renderers/common/Textures.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,30 @@ 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 ( depthTexture === undefined && useDepthTexture ) {
if ( useDepthTexture ) {

depthTexture = new DepthTexture();
depthTexture = renderTarget.depthTexture || depthTextureMips[ activeMipmapLevel ];

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;
if ( depthTexture === undefined ) {

depthTextureMips[ activeMipmapLevel ] = depthTexture;
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;

}

}

Expand Down
Loading