Parcourir la source

TSL: PassNode - Revision linearDepth property (#28737)

sunag il y a 1 an
Parent
commit
1d3c9bd0ac

+ 9 - 7
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();
 
 	}
 

+ 2 - 2
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();
 

+ 1 - 1
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;

+ 1 - 1
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;