Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes: Cache linear depth and viewZ of depth textures in PassNode #28922

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Changes from 3 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
40 changes: 27 additions & 13 deletions src/nodes/display/PassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,35 +169,49 @@ class PassNode extends TempNode {

}

getViewZNode() {
getViewZNode( name = 'depth' ) {

if ( this._viewZNode === null ) {
const depthTextureNode = this.getTextureNode( name );

const cameraNear = this._cameraNear;
const cameraFar = this._cameraFar;
const cameraNear = this._cameraNear;
const cameraFar = this._cameraFar;

this._viewZNode = perspectiveDepthToViewZ( this.getTextureNode( 'depth' ), cameraNear, cameraFar );
if ( name === 'depth' ) {
sunag marked this conversation as resolved.
Show resolved Hide resolved

if ( this._viewZNode === null ) {

this._viewZNode = perspectiveDepthToViewZ( depthTextureNode, cameraNear, cameraFar );

}

return this._viewZNode;

}

return this._viewZNode;
return perspectiveDepthToViewZ( depthTextureNode, cameraNear, cameraFar );

}

getLinearDepthNode() {
getLinearDepthNode( name = 'depth' ) {

const viewZNode = this.getViewZNode( name );

const cameraNear = this._cameraNear;
const cameraFar = this._cameraFar;

if ( name === 'depth' ) {

if ( this._linearDepthNode === null ) {
if ( this._linearDepthNode === null ) {

const cameraNear = this._cameraNear;
const cameraFar = this._cameraFar;
this._linearDepthNode = viewZToOrthographicDepth( viewZNode, cameraNear, cameraFar );

// TODO: just if ( builder.camera.isPerspectiveCamera )
cmhhelgeson marked this conversation as resolved.
Show resolved Hide resolved
}

this._linearDepthNode = viewZToOrthographicDepth( this.getViewZNode(), cameraNear, cameraFar );
return this._linearDepthNode;

}

return this._linearDepthNode;
return viewZToOrthographicDepth( viewZNode, cameraNear, cameraFar );

}

Expand Down