Просмотр исходного кода

TextureNode: Rename `.uv()` -> `.sample()` (#30061)

sunag 1 год назад
Родитель
Сommit
ed96b8dc2a
33 измененных файлов с 108 добавлено и 100 удалено
  1. 10 10
      examples/jsm/misc/ProgressiveLightMapGPU.js
  2. 2 2
      examples/jsm/objects/Water2Mesh.js
  3. 4 4
      examples/jsm/objects/WaterMesh.js
  4. 1 1
      examples/jsm/tsl/display/AfterImageNode.js
  5. 2 2
      examples/jsm/tsl/display/AnaglyphPassNode.js
  6. 1 1
      examples/jsm/tsl/display/AnamorphicNode.js
  7. 1 1
      examples/jsm/tsl/display/BloomNode.js
  8. 4 4
      examples/jsm/tsl/display/DenoiseNode.js
  9. 1 1
      examples/jsm/tsl/display/DepthOfFieldNode.js
  10. 1 1
      examples/jsm/tsl/display/FXAANode.js
  11. 3 3
      examples/jsm/tsl/display/GTAONode.js
  12. 2 2
      examples/jsm/tsl/display/GaussianBlurNode.js
  13. 1 1
      examples/jsm/tsl/display/LensflareNode.js
  14. 1 1
      examples/jsm/tsl/display/Lut3DNode.js
  15. 1 1
      examples/jsm/tsl/display/MotionBlur.js
  16. 8 8
      examples/jsm/tsl/display/OutlineNode.js
  17. 2 2
      examples/jsm/tsl/display/ParallaxBarrierPassNode.js
  18. 3 3
      examples/jsm/tsl/display/PixelationPassNode.js
  19. 1 1
      examples/jsm/tsl/display/RGBShiftNode.js
  20. 24 24
      examples/jsm/tsl/display/SMAANode.js
  21. 4 4
      examples/jsm/tsl/display/SSRNode.js
  22. 1 1
      examples/jsm/tsl/display/SobelOperatorNode.js
  23. 5 5
      examples/jsm/tsl/display/TRAAPassNode.js
  24. 1 1
      examples/jsm/tsl/display/TransitionNode.js
  25. 1 1
      examples/jsm/tsl/display/hashBlur.js
  26. 1 1
      examples/webgpu_volume_cloud.html
  27. 1 1
      src/materials/nodes/VolumeNodeMaterial.js
  28. 3 3
      src/nodes/accessors/Texture3DNode.js
  29. 2 2
      src/nodes/accessors/TextureBicubic.js
  30. 9 1
      src/nodes/accessors/TextureNode.js
  31. 3 3
      src/nodes/functions/PhysicalLightingModel.js
  32. 3 3
      src/nodes/lighting/ShadowNode.js
  33. 1 1
      src/nodes/pmrem/PMREMUtils.js

+ 10 - 10
examples/jsm/misc/ProgressiveLightMapGPU.js

@@ -50,7 +50,7 @@ class ProgressiveLightMap {
 
 		this._uvMat = new MeshPhongNodeMaterial();
 		this._uvMat.vertexNode = vec4( sub( uvNode, vec2( 0.5 ) ).mul( 2 ), 1, 1 );
-		this._uvMat.outputNode = vec4( mix( this._previousShadowMap.uv( uv( 1 ) ), output, float( 1 ).div( this._averagingWindow ) ) );
+		this._uvMat.outputNode = vec4( mix( this._previousShadowMap.sample( uv( 1 ) ), output, float( 1 ).div( this._averagingWindow ) ) );
 
 	}
 
@@ -229,7 +229,7 @@ class ProgressiveLightMap {
 		if ( this._labelMesh === null ) {
 
 			const labelMaterial = new NodeMaterial();
-			labelMaterial.colorNode = texture( this._progressiveLightMap1.texture ).uv( uv().flipY() );
+			labelMaterial.colorNode = texture( this._progressiveLightMap1.texture ).sample( uv().flipY() );
 			labelMaterial.side = DoubleSide;
 
 			const labelGeometry = new PlaneGeometry( 100, 100 );
@@ -267,14 +267,14 @@ class ProgressiveLightMap {
 		const pixelOffset = float( 0.5 ).div( float( this.resolution ) ).toVar();
 
 		const color = add(
-			this._previousShadowMap.uv( uvNode.add( vec2( pixelOffset, 0 ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( 0, pixelOffset ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( 0, pixelOffset.negate() ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( pixelOffset.negate(), 0 ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( pixelOffset, pixelOffset ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( pixelOffset.negate(), pixelOffset ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( pixelOffset, pixelOffset.negate() ) ) ),
-			this._previousShadowMap.uv( uvNode.add( vec2( pixelOffset.negate(), pixelOffset.negate() ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( pixelOffset, 0 ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( 0, pixelOffset ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( 0, pixelOffset.negate() ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( pixelOffset.negate(), 0 ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( pixelOffset, pixelOffset ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( pixelOffset.negate(), pixelOffset ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( pixelOffset, pixelOffset.negate() ) ) ),
+			this._previousShadowMap.sample( uvNode.add( vec2( pixelOffset.negate(), pixelOffset.negate() ) ) ),
 		).div( 8 );
 
 		blurMaterial.fragmentNode = color;

+ 2 - 2
examples/jsm/objects/Water2Mesh.js

@@ -122,8 +122,8 @@ class WaterNode extends TempNode {
 			const normalUv0 = uvs.mul( this.scale ).add( flow.mul( flowMapOffset0 ) );
 			const normalUv1 = uvs.mul( this.scale ).add( flow.mul( flowMapOffset1 ) );
 
-			const normalColor0 = this.normalMap0.uv( normalUv0 );
-			const normalColor1 = this.normalMap1.uv( normalUv1 );
+			const normalColor0 = this.normalMap0.sample( normalUv0 );
+			const normalColor1 = this.normalMap1.sample( normalUv1 );
 
 			// linear interpolate to get the final normal color
 			const flowLerp = abs( halfCycle.sub( flowMapOffset0 ) ).div( halfCycle );

+ 4 - 4
examples/jsm/objects/WaterMesh.js

@@ -47,10 +47,10 @@ class WaterMesh extends Mesh {
 			const uv2 = add( div( uv, vec2( 8907.0, 9803.0 ) ), vec2( div( offset, 101 ), div( offset, 97 ) ) ).toVar();
 			const uv3 = sub( div( uv, vec2( 1091.0, 1027.0 ) ), vec2( div( offset, 109 ), div( offset, - 113 ) ) ).toVar();
 
-			const sample0 = this.waterNormals.uv( uv0 );
-			const sample1 = this.waterNormals.uv( uv1 );
-			const sample2 = this.waterNormals.uv( uv2 );
-			const sample3 = this.waterNormals.uv( uv3 );
+			const sample0 = this.waterNormals.sample( uv0 );
+			const sample1 = this.waterNormals.sample( uv1 );
+			const sample2 = this.waterNormals.sample( uv2 );
+			const sample3 = this.waterNormals.sample( uv3 );
 
 			const noise = sample0.add( sample1 ).add( sample2 ).add( sample3 );
 

+ 1 - 1
examples/jsm/tsl/display/AfterImageNode.js

@@ -101,7 +101,7 @@ class AfterImageNode extends TempNode {
 
 		textureNodeOld.uvNode = uvNode;
 
-		const sampleTexture = ( uv ) => textureNode.uv( uv );
+		const sampleTexture = ( uv ) => textureNode.sample( uv );
 
 		const when_gt = Fn( ( [ x_immutable, y_immutable ] ) => {
 

+ 2 - 2
examples/jsm/tsl/display/AnaglyphPassNode.js

@@ -38,8 +38,8 @@ class AnaglyphPassNode extends StereoCompositePassNode {
 
 		const anaglyph = Fn( () => {
 
-			const colorL = this._mapLeft.uv( uvNode );
-			const colorR = this._mapRight.uv( uvNode );
+			const colorL = this._mapLeft.sample( uvNode );
+			const colorR = this._mapRight.sample( uvNode );
 
 			const color = clamp( this._colorMatrixLeft.mul( colorL.rgb ).add( this._colorMatrixRight.mul( colorR.rgb ) ) );
 

+ 1 - 1
examples/jsm/tsl/display/AnamorphicNode.js

@@ -90,7 +90,7 @@ class AnamorphicNode extends TempNode {
 		const textureNode = this.textureNode;
 		const uvNode = textureNode.uvNode || uv();
 
-		const sampleTexture = ( uv ) => textureNode.uv( uv );
+		const sampleTexture = ( uv ) => textureNode.sample( uv );
 
 		const threshold = ( color, threshold ) => mix( vec3( 0.0 ), color, luminance( color ).sub( threshold ).max( 0 ) );
 

+ 1 - 1
examples/jsm/tsl/display/BloomNode.js

@@ -268,7 +268,7 @@ class BloomNode extends TempNode {
 		const direction = uniform( new Vector2( 0.5, 0.5 ) );
 
 		const uvNode = uv();
-		const sampleTexel = ( uv ) => colorTexture.uv( uv );
+		const sampleTexel = ( uv ) => colorTexture.sample( uv );
 
 		const seperableBlurPass = Fn( () => {
 

+ 4 - 4
examples/jsm/tsl/display/DenoiseNode.js

@@ -48,10 +48,10 @@ class DenoiseNode extends TempNode {
 
 		const uvNode = uv();
 
-		const sampleTexture = ( uv ) => this.textureNode.uv( uv );
-		const sampleDepth = ( uv ) => this.depthNode.uv( uv ).x;
-		const sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.uv( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );
-		const sampleNoise = ( uv ) => this.noiseNode.uv( uv );
+		const sampleTexture = ( uv ) => this.textureNode.sample( uv );
+		const sampleDepth = ( uv ) => this.depthNode.sample( uv ).x;
+		const sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );
+		const sampleNoise = ( uv ) => this.noiseNode.sample( uv );
 
 		const denoiseSample = Fn( ( [ center, viewNormal, viewPosition, sampleUv ] ) => {
 

+ 1 - 1
examples/jsm/tsl/display/DepthOfFieldNode.js

@@ -39,7 +39,7 @@ class DepthOfFieldNode extends TempNode {
 		const textureNode = this.textureNode;
 		const uvNode = textureNode.uvNode || uv();
 
-		const sampleTexture = ( uv ) => textureNode.uv( uv );
+		const sampleTexture = ( uv ) => textureNode.sample( uv );
 
 		const dof = Fn( () => {
 

+ 1 - 1
examples/jsm/tsl/display/FXAANode.js

@@ -44,7 +44,7 @@ class FXAANode extends TempNode {
 
 		const Sample = Fn( ( [ uv ] ) => {
 
-			return textureNode.uv( uv );
+			return textureNode.sample( uv );
 
 		} );
 

+ 3 - 3
examples/jsm/tsl/display/GTAONode.js

@@ -111,7 +111,7 @@ class GTAONode extends TempNode {
 
 		const sampleDepth = ( uv ) => {
 
-			const depth = this.depthNode.uv( uv ).r;
+			const depth = this.depthNode.sample( uv ).r;
 
 			if ( builder.renderer.logarithmicDepthBuffer === true ) {
 
@@ -125,8 +125,8 @@ class GTAONode extends TempNode {
 
 		};
 
-		const sampleNoise = ( uv ) => this._noiseNode.uv( uv );
-		const sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.uv( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );
+		const sampleNoise = ( uv ) => this._noiseNode.sample( uv );
+		const sampleNormal = ( uv ) => ( this.normalNode !== null ) ? this.normalNode.sample( uv ).rgb.normalize() : getNormalFromDepth( uv, this.depthNode.value, this._cameraProjectionMatrixInverse );
 
 		const ao = Fn( () => {
 

+ 2 - 2
examples/jsm/tsl/display/GaussianBlurNode.js

@@ -162,12 +162,12 @@ class GaussianBlurNode extends TempNode {
 
 			// https://lisyarus.github.io/blog/posts/blur-coefficients-generator.html
 
-			sampleTexture = ( uv ) => premult( textureNode.uv( uv ) );
+			sampleTexture = ( uv ) => premult( textureNode.sample( uv ) );
 			output = ( color ) => unpremult( color );
 
 		} else {
 
-			sampleTexture = ( uv ) => textureNode.uv( uv );
+			sampleTexture = ( uv ) => textureNode.sample( uv );
 			output = ( color ) => color;
 
 		}

+ 1 - 1
examples/jsm/tsl/display/LensflareNode.js

@@ -128,7 +128,7 @@ class LensflareNode extends TempNode {
 
 				// accumulate
 
-				let sample = this.textureNode.uv( sampleUv ).rgb;
+				let sample = this.textureNode.sample( sampleUv ).rgb;
 
 				sample = max( sample.sub( this.thresholdNode ), vec3( 0 ) ).mul( this.ghostTintNode );
 

+ 1 - 1
examples/jsm/tsl/display/Lut3DNode.js

@@ -24,7 +24,7 @@ class Lut3DNode extends TempNode {
 
 		const { inputNode, lutNode } = this;
 
-		const sampleLut = ( uv ) => lutNode.uv( uv );
+		const sampleLut = ( uv ) => lutNode.sample( uv );
 
 		const lut3D = Fn( () => {
 

+ 1 - 1
examples/jsm/tsl/display/MotionBlur.js

@@ -3,7 +3,7 @@ import { Fn, float, uv, Loop, int } from 'three/tsl';
 
 export const motionBlur = /*@__PURE__*/ Fn( ( [ inputNode, velocity, numSamples = int( 16 ) ] ) => {
 
-	const sampleColor = ( uv ) => inputNode.uv( uv );
+	const sampleColor = ( uv ) => inputNode.sample( uv );
 
 	const uvs = uv();
 

+ 8 - 8
examples/jsm/tsl/display/OutlineNode.js

@@ -265,7 +265,7 @@ class OutlineNode extends TempNode {
 
 		const prepareMask = () => {
 
-			const depth = this._depthTextureUniform.uv( screenUV );
+			const depth = this._depthTextureUniform.sample( screenUV );
 
 			let viewZNode;
 
@@ -301,10 +301,10 @@ class OutlineNode extends TempNode {
 			const uvOffset = vec4( 1.0, 0.0, 0.0, 1.0 ).mul( vec4( invSize, invSize ) );
 
 			const uvNode = uv();
-			const c1 = this._maskTextureDownsSampleUniform.uv( uvNode.add( uvOffset.xy ) ).toVar();
-			const c2 = this._maskTextureDownsSampleUniform.uv( uvNode.sub( uvOffset.xy ) ).toVar();
-			const c3 = this._maskTextureDownsSampleUniform.uv( uvNode.add( uvOffset.yw ) ).toVar();
-			const c4 = this._maskTextureDownsSampleUniform.uv( uvNode.sub( uvOffset.yw ) ).toVar();
+			const c1 = this._maskTextureDownsSampleUniform.sample( uvNode.add( uvOffset.xy ) ).toVar();
+			const c2 = this._maskTextureDownsSampleUniform.sample( uvNode.sub( uvOffset.xy ) ).toVar();
+			const c3 = this._maskTextureDownsSampleUniform.sample( uvNode.add( uvOffset.yw ) ).toVar();
+			const c4 = this._maskTextureDownsSampleUniform.sample( uvNode.sub( uvOffset.yw ) ).toVar();
 
 			const diff1 = mul( c1.r.sub( c2.r ), 0.5 );
 			const diff2 = mul( c3.r.sub( c4.r ), 0.5 );
@@ -338,7 +338,7 @@ class OutlineNode extends TempNode {
 
 			const sigma = kernelRadius.div( 2 ).toVar();
 			const weightSum = gaussianPdf( 0, sigma ).toVar();
-			const diffuseSum = this._blurColorTextureUniform.uv( uvNode ).mul( weightSum ).toVar();
+			const diffuseSum = this._blurColorTextureUniform.sample( uvNode ).mul( weightSum ).toVar();
 			const delta = this._blurDirection.mul( invSize ).mul( kernelRadius ).div( MAX_RADIUS ).toVar();
 
 			const uvOffset = delta.toVar();
@@ -347,8 +347,8 @@ class OutlineNode extends TempNode {
 
 				const x = kernelRadius.mul( float( i ) ).div( MAX_RADIUS );
 				const w = gaussianPdf( x, sigma );
-				const sample1 = this._blurColorTextureUniform.uv( uvNode.add( uvOffset ) );
-				const sample2 = this._blurColorTextureUniform.uv( uvNode.sub( uvOffset ) );
+				const sample1 = this._blurColorTextureUniform.sample( uvNode.add( uvOffset ) );
+				const sample2 = this._blurColorTextureUniform.sample( uvNode.sub( uvOffset ) );
 
 				diffuseSum.addAssign( sample1.add( sample2 ).mul( w ) );
 				weightSum.addAssign( w.mul( 2 ) );

+ 2 - 2
examples/jsm/tsl/display/ParallaxBarrierPassNode.js

@@ -28,11 +28,11 @@ class ParallaxBarrierPassNode extends StereoCompositePassNode {
 
 			If( mod( screenCoordinate.y, 2 ).greaterThan( 1 ), () => {
 
-				color.assign( this._mapLeft.uv( uvNode ) );
+				color.assign( this._mapLeft.sample( uvNode ) );
 
 			} ).Else( () => {
 
-				color.assign( this._mapRight.uv( uvNode ) );
+				color.assign( this._mapRight.sample( uvNode ) );
 
 			} );
 

+ 3 - 3
examples/jsm/tsl/display/PixelationPassNode.js

@@ -52,11 +52,11 @@ class PixelationNode extends TempNode {
 		const uvNodeDepth = depthNode.uvNode || uv();
 		const uvNodeNormal = normalNode.uvNode || uv();
 
-		const sampleTexture = () => textureNode.uv( uvNodeTexture );
+		const sampleTexture = () => textureNode.sample( uvNodeTexture );
 
-		const sampleDepth = ( x, y ) => depthNode.uv( uvNodeDepth.add( vec2( x, y ).mul( this._resolution.zw ) ) ).r;
+		const sampleDepth = ( x, y ) => depthNode.sample( uvNodeDepth.add( vec2( x, y ).mul( this._resolution.zw ) ) ).r;
 
-		const sampleNormal = ( x, y ) => normalNode.uv( uvNodeNormal.add( vec2( x, y ).mul( this._resolution.zw ) ) ).rgb.normalize();
+		const sampleNormal = ( x, y ) => normalNode.sample( uvNodeNormal.add( vec2( x, y ).mul( this._resolution.zw ) ) ).rgb.normalize();
 
 		const depthEdgeIndicator = ( depth ) => {
 

+ 1 - 1
examples/jsm/tsl/display/RGBShiftNode.js

@@ -25,7 +25,7 @@ class RGBShiftNode extends TempNode {
 
 		const uvNode = textureNode.uvNode || uv();
 
-		const sampleTexture = ( uv ) => textureNode.uv( uv );
+		const sampleTexture = ( uv ) => textureNode.sample( uv );
 
 		const rgbShift = Fn( () => {
 

+ 24 - 24
examples/jsm/tsl/display/SMAANode.js

@@ -192,14 +192,14 @@ class SMAANode extends TempNode {
 
 			// Calculate color deltas:
 			const delta = vec4().toVar();
-			const C = this.textureNode.uv( uvNode ).rgb.toVar();
+			const C = this.textureNode.sample( uvNode ).rgb.toVar();
 
 			// Calculate left and top deltas:
-			const Cleft = this.textureNode.uv( vOffset0.xy ).rgb.toVar();
+			const Cleft = this.textureNode.sample( vOffset0.xy ).rgb.toVar();
 			let t = abs( C.sub( Cleft ) );
 			delta.x = max( max( t.r, t.g ), t.b );
 
-			const Ctop = this.textureNode.uv( vOffset0.zw ).rgb.toVar();
+			const Ctop = this.textureNode.sample( vOffset0.zw ).rgb.toVar();
 			t = abs( C.sub( Ctop ) );
 			delta.y = max( max( t.r, t.g ), t.b );
 
@@ -210,11 +210,11 @@ class SMAANode extends TempNode {
 			dot( edges, vec2( 1.0, 1.0 ) ).equal( 0 ).discard();
 
 			// Calculate right and bottom deltas:
-			const Cright = this.textureNode.uv( vOffset1.xy ).rgb.toVar();
+			const Cright = this.textureNode.sample( vOffset1.xy ).rgb.toVar();
 			t = abs( C.sub( Cright ) );
 			delta.z = max( max( t.r, t.g ), t.b );
 
-			const Cbottom = this.textureNode.uv( vOffset1.zw ).rgb.toVar();
+			const Cbottom = this.textureNode.sample( vOffset1.zw ).rgb.toVar();
 			t = abs( C.sub( Cbottom ) );
 			delta.w = max( max( t.r, t.g ), t.b );
 
@@ -222,11 +222,11 @@ class SMAANode extends TempNode {
 			let maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w ).toVar();
 
 			// Calculate left-left and top-top deltas:
-			const Cleftleft = this.textureNode.uv( vOffset2.xy ).rgb.toVar();
+			const Cleftleft = this.textureNode.sample( vOffset2.xy ).rgb.toVar();
 			t = abs( C.sub( Cleftleft ) );
 			delta.z = max( max( t.r, t.g ), t.b );
 
-			const Ctoptop = this.textureNode.uv( vOffset2.zw ).rgb.toVar();
+			const Ctoptop = this.textureNode.sample( vOffset2.zw ).rgb.toVar();
 			t = abs( C.sub( Ctoptop ) );
 			delta.w = max( max( t.r, t.g ), t.b );
 
@@ -249,7 +249,7 @@ class SMAANode extends TempNode {
 			// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE + e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
 			const coord = vec2( e ).toVar();
 			coord.r = bias.add( coord.r.mul( scale ) );
-			return float( 255 ).mul( searchTex.uv( coord ) ).r;
+			return float( 255 ).mul( searchTex.sample( coord ) ).r;
 
 		} );
 
@@ -264,7 +264,7 @@ class SMAANode extends TempNode {
 			// Move to proper place, according to the subpixel offset:
 			texcoord.y.addAssign( float( SMAA_AREATEX_SUBTEX_SIZE ).mul( offset ) );
 
-			return areaTex.uv( texcoord ).rg;
+			return areaTex.sample( texcoord ).rg;
 
 		} );
 
@@ -283,7 +283,7 @@ class SMAANode extends TempNode {
 
 			Loop( { start: int( 0 ), end: int( SMAA_MAX_SEARCH_STEPS ), type: 'int', condition: '<' }, () => { // port note: Changed while to for
 
-				e.assign( edgesTex.uv( coord ).rg );
+				e.assign( edgesTex.sample( coord ).rg );
 				coord.subAssign( vec2( 2, 0 ).mul( this._invSize ) );
 
 				If( coord.x.lessThanEqual( end ).or( e.g.lessThanEqual( float( 0.8281 ) ).or( e.r.notEqual( float( 0 ) ) ) ), () => {
@@ -315,7 +315,7 @@ class SMAANode extends TempNode {
 
 			Loop( { start: int( 0 ), end: int( SMAA_MAX_SEARCH_STEPS ), type: 'int', condition: '<' }, () => { // port note: Changed while to for
 
-				e.assign( edgesTex.uv( coord ).rg );
+				e.assign( edgesTex.sample( coord ).rg );
 				coord.addAssign( vec2( 2, 0 ).mul( this._invSize ) );
 
 				If( coord.x.greaterThanEqual( end ).or( e.g.lessThanEqual( float( 0.8281 ) ).or( e.r.notEqual( float( 0 ) ) ) ), () => {
@@ -342,7 +342,7 @@ class SMAANode extends TempNode {
 
 			Loop( { start: int( 0 ), end: int( SMAA_MAX_SEARCH_STEPS ), type: 'int', condition: '<' }, () => { // port note: Changed while to for
 
-				e.assign( edgesTex.uv( coord ).rg );
+				e.assign( edgesTex.sample( coord ).rg );
 				coord.addAssign( vec2( 0, - 2 ).mul( this._invSize ) );
 
 				If( coord.y.lessThanEqual( end ).or( e.r.lessThanEqual( float( 0.8281 ) ).or( e.g.notEqual( float( 0 ) ) ) ), () => {
@@ -369,7 +369,7 @@ class SMAANode extends TempNode {
 
 			Loop( { start: int( 0 ), end: int( SMAA_MAX_SEARCH_STEPS ), type: 'int', condition: '<' }, () => { // port note: Changed while to for
 
-				e.assign( edgesTex.uv( coord ).rg );
+				e.assign( edgesTex.sample( coord ).rg );
 				coord.subAssign( vec2( 0, - 2 ).mul( this._invSize ) );
 
 				If( coord.y.greaterThanEqual( end ).or( e.r.lessThanEqual( float( 0.8281 ) ).or( e.g.notEqual( float( 0 ) ) ) ), () => {
@@ -419,7 +419,7 @@ class SMAANode extends TempNode {
 			const weights = vec4( 0.0, 0.0, 0.0, 0.0 ).toVar();
 			const subsampleIndices = vec4( 0.0, 0.0, 0.0, 0.0 ).toVar();
 
-			const e = this._edgesTextureUniform.uv( uvNode ).rg.toVar();
+			const e = this._edgesTextureUniform.sample( uvNode ).rg.toVar();
 
 			If( e.g.greaterThan( float( 0 ) ), () => { // Edge at north
 
@@ -435,7 +435,7 @@ class SMAANode extends TempNode {
 				// Now fetch the left crossing edges, two at a time using bilinear
 				// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
 				// discern what value each edge has:
-				const e1 = this._edgesTextureUniform.uv( coordsLeft ).r.toVar();
+				const e1 = this._edgesTextureUniform.sample( coordsLeft ).r.toVar();
 
 				// Find the distance to the right:
 				const coordsRight = vec2().toVar();
@@ -451,7 +451,7 @@ class SMAANode extends TempNode {
 				const sqrt_d = sqrt( abs( d ) );
 
 				// Fetch the right crossing edges:
-				const e2 = this._edgesTextureUniform.uv( coordsRight.add( vec2( 1, 0 ).mul( this._invSize ) ) ).r.toVar();
+				const e2 = this._edgesTextureUniform.sample( coordsRight.add( vec2( 1, 0 ).mul( this._invSize ) ) ).r.toVar();
 				weights.r = e2;
 
 				// Get the area for this direction:
@@ -471,7 +471,7 @@ class SMAANode extends TempNode {
 				d.x = coordsUp.y;
 
 				// Fetch the top crossing edges:
-				const e1 = this._edgesTextureUniform.uv( coordsUp ).g.toVar();
+				const e1 = this._edgesTextureUniform.sample( coordsUp ).g.toVar();
 
 				// Find the distance to the bottom:
 				const coordsDown = vec2().toVar();
@@ -486,7 +486,7 @@ class SMAANode extends TempNode {
 				const sqrt_d = sqrt( abs( d ) );
 
 				// Fetch the bottom crossing edges:
-				const e2 = this._edgesTextureUniform.uv( coordsDown.add( vec2( 0, 1 ).mul( this._invSize ) ) ).g.toVar();
+				const e2 = this._edgesTextureUniform.sample( coordsDown.add( vec2( 0, 1 ).mul( this._invSize ) ) ).g.toVar();
 
 				// Get the area for this direction:
 				weights.ba = SMAAArea( this._areaTextureUniform, sqrt_d, e1, e2, float( subsampleIndices.x ) );
@@ -520,15 +520,15 @@ class SMAANode extends TempNode {
 			// Fetch the blending weights for current pixel:
 
 			const a = vec4().toVar();
-			a.xz = this._weightsTextureUniform.uv( uvNode ).xz;
-			a.y = this._weightsTextureUniform.uv( vOffset1.zw ).g;
-			a.w = this._weightsTextureUniform.uv( vOffset1.xy ).a;
+			a.xz = this._weightsTextureUniform.sample( uvNode ).xz;
+			a.y = this._weightsTextureUniform.sample( vOffset1.zw ).g;
+			a.w = this._weightsTextureUniform.sample( vOffset1.xy ).a;
 
 			// Is there any blending weight with a value greater than 0.0?
 
 			If( dot( a, vec4( 1.0 ) ).lessThan( 1e-5 ), () => { // Edge at north
 
-				result.assign( this.textureNode.uv( uvNode ) );
+				result.assign( this.textureNode.sample( uvNode ) );
 
 			} ).Else( () => {
 
@@ -555,10 +555,10 @@ class SMAANode extends TempNode {
 
 				// Fetch the opposite color and lerp by hand:
 
-				const C = this.textureNode.uv( uvNode ).toVar();
+				const C = this.textureNode.sample( uvNode ).toVar();
 				const texcoord = vec2( uvNode ).toVar();
 				texcoord.addAssign( sign( offset ).mul( this._invSize ) );
-				const Cop = this.textureNode.uv( texcoord ).toVar();
+				const Cop = this.textureNode.sample( texcoord ).toVar();
 				const s = abs( offset.x ).greaterThan( abs( offset.y ) ).select( abs( offset.x ), abs( offset.y ) ).toVar();
 
 				const mixed = mix( C, Cop, s );

+ 4 - 4
examples/jsm/tsl/display/SSRNode.js

@@ -153,7 +153,7 @@ class SSRNode extends TempNode {
 
 		const sampleDepth = ( uv ) => {
 
-			const depth = this.depthNode.uv( uv ).r;
+			const depth = this.depthNode.sample( uv ).r;
 
 			if ( builder.renderer.logarithmicDepthBuffer === true ) {
 
@@ -169,7 +169,7 @@ class SSRNode extends TempNode {
 
 		const ssr = Fn( () => {
 
-			const metalness = this.metalnessNode.uv( uvNode ).r;
+			const metalness = this.metalnessNode.sample( uvNode ).r;
 
 			// fragments with no metalness do not reflect their environment
 			metalness.equal( 0.0 ).discard();
@@ -295,7 +295,7 @@ class SSRNode extends TempNode {
 
 					If( away.lessThanEqual( tk ), () => { // hit
 
-						const vN = this.normalNode.uv( uvNode ).rgb.normalize().toVar();
+						const vN = this.normalNode.sample( uvNode ).rgb.normalize().toVar();
 
 						If( dot( viewReflectDir, vN ).greaterThanEqual( 0 ), () => {
 
@@ -328,7 +328,7 @@ class SSRNode extends TempNode {
 						op.mulAssign( fresnelCoe );
 
 						// output
-						const reflectColor = this.colorNode.uv( uvNode );
+						const reflectColor = this.colorNode.sample( uvNode );
 						output.assign( vec4( reflectColor.rgb, op ) );
 						Break();
 

+ 1 - 1
examples/jsm/tsl/display/SobelOperatorNode.js

@@ -35,7 +35,7 @@ class SobelOperatorNode extends TempNode {
 
 		const uvNode = textureNode.uvNode || uv();
 
-		const sampleTexture = ( uv ) => textureNode.uv( uv );
+		const sampleTexture = ( uv ) => textureNode.sample( uv );
 
 		const sobel = Fn( () => {
 

+ 5 - 5
examples/jsm/tsl/display/TRAAPassNode.js

@@ -260,12 +260,12 @@ class TRAAPassNode extends PassNode {
 				Loop( { start: int( - 1 ), end: int( 1 ), type: 'int', condition: '<=', name: 'y' }, ( { y } ) => {
 
 					const uvNeighbor = uvNode.add( vec2( float( x ), float( y ) ).mul( this._invSize ) ).toVar();
-					const colorNeighbor = max( vec4( 0 ), sampleTexture.uv( uvNeighbor ) ).toVar(); // use max() to avoid propagate garbage values
+					const colorNeighbor = max( vec4( 0 ), sampleTexture.sample( uvNeighbor ) ).toVar(); // use max() to avoid propagate garbage values
 
 					minColor.assign( min( minColor, colorNeighbor ) );
 					maxColor.assign( max( maxColor, colorNeighbor ) );
 
-					const currentDepth = depthTexture.uv( uvNeighbor ).r.toVar();
+					const currentDepth = depthTexture.sample( uvNeighbor ).r.toVar();
 
 					// find the sample position of the closest depth in the neighborhood (used for velocity)
 
@@ -282,10 +282,10 @@ class TRAAPassNode extends PassNode {
 
 			// sampling/reprojection
 
-			const offset = velocityTexture.uv( closestDepthPixelPosition ).xy.mul( vec2( 0.5, - 0.5 ) ); // NDC to uv offset
+			const offset = velocityTexture.sample( closestDepthPixelPosition ).xy.mul( vec2( 0.5, - 0.5 ) ); // NDC to uv offset
 
-			const currentColor = sampleTexture.uv( uvNode );
-			const historyColor = historyTexture.uv( uvNode.sub( offset ) );
+			const currentColor = sampleTexture.sample( uvNode );
+			const historyColor = historyTexture.sample( uvNode.sub( offset ) );
 
 			// clamping
 

+ 1 - 1
examples/jsm/tsl/display/TransitionNode.js

@@ -34,7 +34,7 @@ class TransitionNode extends TempNode {
 		const sampleTexture = ( textureNode ) => {
 
 			const uvNodeTexture = textureNode.uvNode || uv();
-			return textureNode.uv( uvNodeTexture );
+			return textureNode.sample( uvNodeTexture );
 
 		};
 

+ 1 - 1
examples/jsm/tsl/display/hashBlur.js

@@ -4,7 +4,7 @@ import { float, Fn, vec2, uv, sin, rand, degrees, cos, Loop, vec4 } from 'three/
 
 export const hashBlur = /*#__PURE__*/ Fn( ( [ textureNode, bluramount = float( 0.1 ), repeats = float( 45 ) ] ) => {
 
-	const draw = ( uv ) => textureNode.uv( uv );
+	const draw = ( uv ) => textureNode.sample( uv );
 
 	const targetUV = textureNode.uvNode || uv();
 	const blurred_image = vec4( 0. ).toVar();

+ 1 - 1
examples/webgpu_volume_cloud.html

@@ -132,7 +132,7 @@
 
 					mapValue.assign( smoothstep( threshold.sub( range ), threshold.add( range ), mapValue ).mul( opacity ) );
 
-					const shading = map.uv( probe.add( vec3( - 0.01 ) ) ).r.sub( map.uv( probe.add( vec3( 0.01 ) ) ).r );
+					const shading = map.sample( probe.add( vec3( - 0.01 ) ) ).r.sub( map.sample( probe.add( vec3( 0.01 ) ) ).r );
 
 					const col = shading.mul( 3.0 ).add( probe.x.add( probe.y ).mul( 0.25 ) ).add( 0.2 );
 

+ 1 - 1
src/materials/nodes/VolumeNodeMaterial.js

@@ -75,7 +75,7 @@ class VolumeNodeMaterial extends NodeMaterial {
 
 			Loop( { type: 'float', start: bounds.x, end: bounds.y, update: '+= delta' }, () => {
 
-				const d = property( 'float', 'd' ).assign( map.uv( p.add( 0.5 ) ).r );
+				const d = property( 'float', 'd' ).assign( map.sample( p.add( 0.5 ) ).r );
 
 				if ( this.testNode !== null ) {
 

+ 3 - 3
src/nodes/accessors/Texture3DNode.js

@@ -35,9 +35,9 @@ const normal = Fn( ( { texture, uv } ) => {
 
 		const step = 0.01;
 
-		const x = texture.uv( uv.add( vec3( - step, 0.0, 0.0 ) ) ).r.sub( texture.uv( uv.add( vec3( step, 0.0, 0.0 ) ) ).r );
-		const y = texture.uv( uv.add( vec3( 0.0, - step, 0.0 ) ) ).r.sub( texture.uv( uv.add( vec3( 0.0, step, 0.0 ) ) ).r );
-		const z = texture.uv( uv.add( vec3( 0.0, 0.0, - step ) ) ).r.sub( texture.uv( uv.add( vec3( 0.0, 0.0, step ) ) ).r );
+		const x = texture.sample( uv.add( vec3( - step, 0.0, 0.0 ) ) ).r.sub( texture.sample( uv.add( vec3( step, 0.0, 0.0 ) ) ).r );
+		const y = texture.sample( uv.add( vec3( 0.0, - step, 0.0 ) ) ).r.sub( texture.sample( uv.add( vec3( 0.0, step, 0.0 ) ) ).r );
+		const z = texture.sample( uv.add( vec3( 0.0, 0.0, - step ) ) ).r.sub( texture.sample( uv.add( vec3( 0.0, 0.0, step ) ) ).r );
 
 		ret.assign( vec3( x, y, z ) );
 

+ 2 - 2
src/nodes/accessors/TextureBicubic.js

@@ -44,8 +44,8 @@ const bicubic = ( textureNode, texelSize, lod ) => {
 	const p2 = vec2( iuv.x.add( h0x ), iuv.y.add( h1y ) ).sub( 0.5 ).mul( texelSize.xy );
 	const p3 = vec2( iuv.x.add( h1x ), iuv.y.add( h1y ) ).sub( 0.5 ).mul( texelSize.xy );
 
-	const a = g0( fuv.y ).mul( add( g0x.mul( textureNode.uv( p0 ).level( lod ) ), g1x.mul( textureNode.uv( p1 ).level( lod ) ) ) );
-	const b = g1( fuv.y ).mul( add( g0x.mul( textureNode.uv( p2 ).level( lod ) ), g1x.mul( textureNode.uv( p3 ).level( lod ) ) ) );
+	const a = g0( fuv.y ).mul( add( g0x.mul( textureNode.sample( p0 ).level( lod ) ), g1x.mul( textureNode.sample( p1 ).level( lod ) ) ) );
+	const b = g1( fuv.y ).mul( add( g0x.mul( textureNode.sample( p2 ).level( lod ) ), g1x.mul( textureNode.sample( p3 ).level( lod ) ) ) );
 
 	return a.add( b );
 

+ 9 - 1
src/nodes/accessors/TextureNode.js

@@ -315,7 +315,15 @@ class TextureNode extends UniformNode {
 
 	// @TODO: Move to TSL
 
-	uv( uvNode ) {
+	uv( uvNode ) { // @deprecated, r172
+
+		console.warn( 'THREE.TextureNode: .uv() has been renamed. Use .sample() instead.' );
+
+		return this.sample( uvNode );
+
+	}
+
+	sample( uvNode ) {
 
 		const textureNode = this.clone();
 		textureNode.uvNode = nodeObject( uvNode );

+ 3 - 3
src/nodes/functions/PhysicalLightingModel.js

@@ -75,7 +75,7 @@ const getTransmissionSample = /*@__PURE__*/ Fn( ( [ fragCoord, roughness, ior ],
 
 	const vTexture = material.side == BackSide ? viewportBackSideTexture : viewportFrontSideTexture;
 
-	const transmissionSample = vTexture.uv( fragCoord );
+	const transmissionSample = vTexture.sample( fragCoord );
 	//const transmissionSample = viewportMipTexture( fragCoord );
 
 	const lod = log2( screenSize.x ).mul( applyIorToRoughness( roughness, ior ) );
@@ -619,8 +619,8 @@ class PhysicalLightingModel extends LightingModel {
 
 		const uv = LTC_Uv( { N, V, roughness } );
 
-		const t1 = ltc_1.uv( uv ).toVar();
-		const t2 = ltc_2.uv( uv ).toVar();
+		const t1 = ltc_1.sample( uv ).toVar();
+		const t2 = ltc_2.sample( uv ).toVar();
 
 		const mInv = mat3(
 			vec3( t1.x, 0, t1.y ),

+ 3 - 3
src/nodes/lighting/ShadowNode.js

@@ -171,7 +171,7 @@ export const VSMShadowFilter = /*@__PURE__*/ Fn( ( { depthTexture, shadowCoord }
 
 	const occlusion = float( 1 ).toVar();
 
-	const distribution = texture( depthTexture ).uv( shadowCoord.xy ).rg;
+	const distribution = texture( depthTexture ).sample( shadowCoord.xy ).rg;
 
 	const hardShadow = step( shadowCoord.z, distribution.x );
 
@@ -201,7 +201,7 @@ const VSMPassVertical = /*@__PURE__*/ Fn( ( { samples, radius, size, shadowPass
 
 		const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
 
-		const depth = shadowPass.uv( add( screenCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( size ) ).x;
+		const depth = shadowPass.sample( add( screenCoordinate.xy, vec2( 0, uvOffset ).mul( radius ) ).div( size ) ).x;
 		mean.addAssign( depth );
 		squaredMean.addAssign( depth.mul( depth ) );
 
@@ -227,7 +227,7 @@ const VSMPassHorizontal = /*@__PURE__*/ Fn( ( { samples, radius, size, shadowPas
 
 		const uvOffset = uvStart.add( float( i ).mul( uvStride ) );
 
-		const distribution = shadowPass.uv( add( screenCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( size ) );
+		const distribution = shadowPass.sample( add( screenCoordinate.xy, vec2( uvOffset, 0 ).mul( radius ) ).div( size ) );
 		mean.addAssign( distribution.x );
 		squaredMean.addAssign( add( distribution.y.mul( distribution.y ), distribution.x.mul( distribution.x ) ) );
 

+ 1 - 1
src/nodes/pmrem/PMREMUtils.js

@@ -237,7 +237,7 @@ const bilinearCubeUV = /*@__PURE__*/ Fn( ( [ envMap, direction_immutable, mipInt
 	uv.x.mulAssign( CUBEUV_TEXEL_WIDTH );
 	uv.y.mulAssign( CUBEUV_TEXEL_HEIGHT );
 
-	return envMap.uv( uv ).grad( vec2(), vec2() ); // disable anisotropic filtering
+	return envMap.sample( uv ).grad( vec2(), vec2() ); // disable anisotropic filtering
 
 } );
 

粤ICP备19079148号