diff --git a/examples/jsm/nodes/display/PassNode.js b/examples/jsm/nodes/display/PassNode.js index acfdd502651ab0..1a8d382be5fc6f 100644 --- a/examples/jsm/nodes/display/PassNode.js +++ b/examples/jsm/nodes/display/PassNode.js @@ -1,6 +1,6 @@ import { addNodeClass } from '../core/Node.js'; import TempNode from '../core/TempNode.js'; -import TextureNode from '../accessors/TextureNode.js'; +import { default as TextureNode/*, texture*/ } from '../accessors/TextureNode.js'; import { NodeUpdateType } from '../core/constants.js'; import { nodeObject } from '../shadernode/ShaderNode.js'; import { uniform } from '../core/UniformNode.js'; @@ -67,7 +67,7 @@ class PassNode extends TempNode { this._textureNode = nodeObject( new PassTextureNode( this, renderTarget.texture ) ); this._depthTextureNode = nodeObject( new PassTextureNode( this, depthTexture ) ); - this._depthNode = null; + this._linearDepthNode = null; this._viewZNode = null; this._cameraNear = uniform( 0 ); this._cameraFar = uniform( 0 ); @@ -109,24 +109,26 @@ class PassNode extends TempNode { } - getDepthNode() { + getLinearDepthNode() { - if ( this._depthNode === null ) { + if ( this._linearDepthNode === null ) { const cameraNear = this._cameraNear; const cameraFar = this._cameraFar; - this._depthNode = viewZToOrthographicDepth( this.getViewZNode(), cameraNear, cameraFar ); + // TODO: just if ( builder.camera.isPerspectiveCamera ) + + this._linearDepthNode = viewZToOrthographicDepth( this.getViewZNode(), cameraNear, cameraFar ); } - return this._depthNode; + return this._linearDepthNode; } setup() { - return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getDepthNode(); + return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode(); } diff --git a/examples/webgpu_backdrop_water.html b/examples/webgpu_backdrop_water.html index 828234e3e95c8b..dacfa55296bbf3 100644 --- a/examples/webgpu_backdrop_water.html +++ b/examples/webgpu_backdrop_water.html @@ -233,12 +233,12 @@ const scenePass = pass( scene, camera ); const scenePassColor = scenePass.getTextureNode(); - const scenePassDepth = scenePass.getDepthNode().remapClamp( .3, .5 ); + const scenePassDepth = scenePass.getLinearDepthNode().remapClamp( .3, .5 ); const waterMask = objectPosition( camera ).y.greaterThan( 0 ); const scenePassColorBlurred = scenePassColor.gaussianBlur(); - scenePassColorBlurred.directionNode = waterMask.cond( scenePassDepth, scenePass.getDepthNode().mul( 5 ) ); + scenePassColorBlurred.directionNode = waterMask.cond( scenePassDepth, scenePass.getLinearDepthNode().mul( 5 ) ); const vignet = viewportTopLeft.distance( .5 ).mul( 1.35 ).clamp().oneMinus(); diff --git a/examples/webgpu_reflection.html b/examples/webgpu_reflection.html index 7d7675321e05d8..fc8dcb0feafadf 100644 --- a/examples/webgpu_reflection.html +++ b/examples/webgpu_reflection.html @@ -160,7 +160,7 @@ const scenePass = pass( scene, camera ); const scenePassColor = scenePass.getTextureNode(); - const scenePassDepth = scenePass.getDepthNode().remapClamp( .3, .5 ); + const scenePassDepth = scenePass.getLinearDepthNode().remapClamp( .3, .5 ); const scenePassColorBlurred = scenePassColor.gaussianBlur(); scenePassColorBlurred.directionNode = scenePassDepth; diff --git a/examples/webgpu_skinning_instancing.html b/examples/webgpu_skinning_instancing.html index 13d208cead37ad..7dd7d96ac24b31 100644 --- a/examples/webgpu_skinning_instancing.html +++ b/examples/webgpu_skinning_instancing.html @@ -144,7 +144,7 @@ const scenePass = pass( scene, camera ); const scenePassColor = scenePass.getTextureNode(); - const scenePassDepth = scenePass.getDepthNode().remapClamp( .15, .3 ); + const scenePassDepth = scenePass.getLinearDepthNode().remapClamp( .15, .3 ); const scenePassColorBlurred = scenePassColor.gaussianBlur(); scenePassColorBlurred.directionNode = scenePassDepth;