Skip to content

Commit

Permalink
TSL: Prevent viewportBottomLeft breaking change and cleanup (#29223)
Browse files Browse the repository at this point in the history
  • Loading branch information
RenaudRohlinger authored Aug 24, 2024
1 parent 676e85d commit 3e6ab2d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/jsm/objects/Water2Mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
Vector2,
Vector3
} from 'three';
import { vec2, viewportSafeUV, viewportSharedTexture, reflector, pow, float, abs, texture, uniform, TempNode, NodeUpdateType, vec4, Fn, cameraPosition, positionWorld, uv, mix, vec3, normalize, max, dot, viewportTopLeft } from 'three/tsl';
import { vec2, viewportSafeUV, viewportSharedTexture, reflector, pow, float, abs, texture, uniform, TempNode, NodeUpdateType, vec4, Fn, cameraPosition, positionWorld, uv, mix, vec3, normalize, max, dot, viewportUV } from 'three/tsl';

/**
* References:
Expand Down Expand Up @@ -141,7 +141,7 @@ class WaterNode extends TempNode {
this.waterBody.add( reflectionSampler.target );
reflectionSampler.uvNode = reflectionSampler.uvNode.add( offset );

const refractorUV = viewportTopLeft.add( offset );
const refractorUV = viewportUV.add( offset );
const refractionSampler = viewportSharedTexture( viewportSafeUV( refractorUV ) );

// calculate final uv coords
Expand Down
4 changes: 2 additions & 2 deletions examples/webgpu_materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script type="module">

import * as THREE from 'three';
import { Fn, wgslFn, positionLocal, positionWorld, normalLocal, normalWorld, normalView, color, texture, uv, float, vec2, vec3, vec4, oscSine, triplanarTexture, viewportBottomLeft, js, string, global, Loop, cameraProjectionMatrix } from 'three/tsl';
import { Fn, wgslFn, positionLocal, positionWorld, normalLocal, normalWorld, normalView, color, texture, uv, float, vec2, vec3, vec4, oscSine, triplanarTexture, viewportUV, js, string, global, Loop, cameraProjectionMatrix } from 'three/tsl';

import { TeapotGeometry } from 'three/addons/geometries/TeapotGeometry.js';

Expand Down Expand Up @@ -206,7 +206,7 @@

// Screen Projection Texture
material = new THREE.MeshBasicNodeMaterial();
material.colorNode = texture( uvTexture, viewportBottomLeft );
material.colorNode = texture( uvTexture, viewportUV.flipY() );
materials.push( material );

// Loop
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export { default as FrontFacingNode, frontFacing, faceDirection } from './displa
export { default as NormalMapNode, normalMap } from './display/NormalMapNode.js';
export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportUV, viewportTopLeft } from './display/ViewportNode.js';
export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportUV, viewportTopLeft, viewportBottomLeft } from './display/ViewportNode.js';
export { default as ViewportTextureNode, viewportTexture, viewportMipTexture } from './display/ViewportTextureNode.js';
export { default as ViewportSharedTextureNode, viewportSharedTexture } from './display/ViewportSharedTextureNode.js';
export { default as ViewportDepthTextureNode, viewportDepthTexture } from './display/ViewportDepthTextureNode.js';
Expand Down
8 changes: 8 additions & 0 deletions src/nodes/display/ViewportNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,12 @@ export const viewportTopLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168

}, 'vec2' ).once() )();

export const viewportBottomLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168

console.warn( 'TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "viewportUV.flipY()" instead.' );

return viewportUV.flipY();

}, 'vec2' ).once() )();

addNodeClass( 'ViewportNode', ViewportNode );

0 comments on commit 3e6ab2d

Please sign in to comment.