From 798097a1cbb9c1e6c0a72ed39dd7ec0d7926f923 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Wed, 21 Aug 2024 23:22:41 -0400 Subject: [PATCH] TSL: Introduce viewportSafeUV() (#1163) * TSL: Introduce viewportSafeUV() * Update three.js * Add examples * Update * Update patch and delete examples * Format --- examples-testing/changes.patch | 13 ++----------- examples-testing/index.js | 1 + three.js | 2 +- types/three/src/nodes/Nodes.d.ts | 1 + types/three/src/nodes/utils/ViewportUtils.d.ts | 4 ++++ 5 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 types/three/src/nodes/utils/ViewportUtils.d.ts diff --git a/examples-testing/changes.patch b/examples-testing/changes.patch index 5a67f8808..69f5a03f7 100644 --- a/examples-testing/changes.patch +++ b/examples-testing/changes.patch @@ -15125,13 +15125,13 @@ index d4228f90..191b58f2 100644 init(); render(); diff --git a/examples-testing/examples/webgpu_refraction.ts b/examples-testing/examples/webgpu_refraction.ts -index dc018c6d..6c7faf4d 100644 +index bf36d911..0e77df7c 100644 --- a/examples-testing/examples/webgpu_refraction.ts +++ b/examples-testing/examples/webgpu_refraction.ts @@ -1,13 +1,13 @@ -import * as THREE from 'three'; +import * as THREE from 'three/webgpu'; - import { viewportSharedTexture, texture, uv } from 'three/tsl'; + import { viewportSafeUV, viewportSharedTexture, viewportTopLeft, texture, uv } from 'three/tsl'; import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; @@ -15146,15 +15146,6 @@ index dc018c6d..6c7faf4d 100644 init(); -@@ -40,7 +40,7 @@ function init() { - - const verticalNormalScale = 0.1; - const verticalUVOffset = texture(floorNormal, uv().mul(5)).xy.mul(2).sub(1).mul(verticalNormalScale); -- verticalRefractor.uvNode = verticalRefractor.uvNode.add(verticalUVOffset); -+ verticalRefractor.uvNode = verticalRefractor.uvNode!.add(verticalUVOffset); - - const planeGeo = new THREE.PlaneGeometry(100.1, 100.1); - diff --git a/examples-testing/examples/webgpu_sky.ts b/examples-testing/examples/webgpu_sky.ts index 60af1c2d..1b7a8906 100644 --- a/examples-testing/examples/webgpu_sky.ts diff --git a/examples-testing/index.js b/examples-testing/index.js index dd548d9a8..932275ad9 100644 --- a/examples-testing/index.js +++ b/examples-testing/index.js @@ -110,6 +110,7 @@ const exceptionList = [ 'webgpu_tsl_procedural_terrain', 'webgpu_tsl_raging_sea', 'webgpu_tsl_transpiler', + 'webgpu_tsl_vfx_tornado', 'webgpu_volume_cloud', 'webgpu_volume_perlin', 'webxr_vr_handinput_cubes', diff --git a/three.js b/three.js index 97d2d20dd..081a8b34a 160000 --- a/three.js +++ b/three.js @@ -1 +1 @@ -Subproject commit 97d2d20dd689a9370db8668745f1045e2abb34ef +Subproject commit 081a8b34a838b4c1c7383236b5eb153af3b8e1fa diff --git a/types/three/src/nodes/Nodes.d.ts b/types/three/src/nodes/Nodes.d.ts index e00b8935e..64491e694 100644 --- a/types/three/src/nodes/Nodes.d.ts +++ b/types/three/src/nodes/Nodes.d.ts @@ -205,6 +205,7 @@ export { triplanarTextures, } from "./utils/TriplanarTexturesNode.js"; export * from "./utils/UVUtils.js"; +export * from "./utils/ViewportUtils.js"; // shader node export * from "./shadernode/ShaderNode.js"; diff --git a/types/three/src/nodes/utils/ViewportUtils.d.ts b/types/three/src/nodes/utils/ViewportUtils.d.ts new file mode 100644 index 000000000..3e971255a --- /dev/null +++ b/types/three/src/nodes/utils/ViewportUtils.d.ts @@ -0,0 +1,4 @@ +import Node from "../core/Node.js"; +import { NodeRepresentation, ShaderNodeObject } from "../shadernode/ShaderNode.js"; + +export const viewportSafeUV: (uv?: NodeRepresentation | null) => ShaderNodeObject;