Skip to content

Commit

Permalink
TextureNode: Rename .uv() -> .sample() (#30061)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag authored Dec 7, 2024
1 parent f5f25c3 commit ed96b8d
Show file tree
Hide file tree
Showing 33 changed files with 108 additions and 100 deletions.
20 changes: 10 additions & 10 deletions examples/jsm/misc/ProgressiveLightMapGPU.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );

}

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/objects/Water2Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions examples/jsm/objects/WaterMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/AfterImageNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ) => {

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/tsl/display/AnaglyphPassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/AnamorphicNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/BloomNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( () => {

Expand Down
8 changes: 4 additions & 4 deletions examples/jsm/tsl/display/DenoiseNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] ) => {

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/DepthOfFieldNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( () => {

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/FXAANode.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FXAANode extends TempNode {

const Sample = Fn( ( [ uv ] ) => {

return textureNode.uv( uv );
return textureNode.sample( uv );

} );

Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/tsl/display/GTAONode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Expand All @@ -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( () => {

Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/tsl/display/GaussianBlurNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/LensflareNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/Lut3DNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( () => {

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/MotionBlur.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
16 changes: 8 additions & 8 deletions examples/jsm/tsl/display/OutlineNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class OutlineNode extends TempNode {

const prepareMask = () => {

const depth = this._depthTextureUniform.uv( screenUV );
const depth = this._depthTextureUniform.sample( screenUV );

let viewZNode;

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand All @@ -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 ) );
Expand Down
4 changes: 2 additions & 2 deletions examples/jsm/tsl/display/ParallaxBarrierPassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );

} );

Expand Down
6 changes: 3 additions & 3 deletions examples/jsm/tsl/display/PixelationPassNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => {

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/tsl/display/RGBShiftNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( () => {

Expand Down
Loading

0 comments on commit ed96b8d

Please sign in to comment.