Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add webgpu_backdrop_water example #809

Merged
merged 6 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.pnp.*
.yarn/*
three.js
pnpm-lock.yaml
types
three.js
50 changes: 50 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13644,6 +13644,56 @@ index a40092c..9dc155c 100644
box.material = materials[name];
});
}
diff --git a/examples-testing/examples/webgpu_backdrop_water.ts b/examples-testing/examples/webgpu_backdrop_water.ts
index 50291c7..7b3aed1 100644
--- a/examples-testing/examples/webgpu_backdrop_water.ts
+++ b/examples-testing/examples/webgpu_backdrop_water.ts
@@ -17,6 +17,8 @@ import {
timerLocal,
MeshStandardNodeMaterial,
MeshBasicNodeMaterial,
+ ShaderNodeObject,
+ Node,
} from 'three/nodes';

import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
@@ -33,12 +35,14 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

import Stats from 'three/addons/libs/stats.module.js';

-let camera, scene, renderer;
-let mixer, objects, clock;
-let model, floor, floorPosition;
-let postProcessing;
-let controls;
-let stats;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: WebGPURenderer;
+let mixer: THREE.AnimationMixer, objects: THREE.Group, clock: THREE.Clock;
+let model: THREE.Group,
+ floor: THREE.Mesh<THREE.CylinderGeometry, MeshStandardNodeMaterial>,
+ floorPosition: THREE.Vector3;
+let postProcessing: PostProcessing;
+let controls: OrbitControls;
+let stats: Stats;

init();

@@ -177,10 +181,13 @@ function init() {

const waterPosY = positionWorld.y.sub(water.position.y);

- let transition = waterPosY.add(0.1).saturate().oneMinus();
+ let transition: ShaderNodeObject<Node> = waterPosY.add(0.1).saturate().oneMinus();
transition = waterPosY.lessThan(0).cond(transition, normalWorld.y.mix(transition, 0)).toVar();

- const colorNode = transition.mix(material.colorNode, material.colorNode.add(waterLayer0));
+ const colorNode = transition.mix(
+ material.colorNode!,
+ (material.colorNode as ShaderNodeObject<Node>).add(waterLayer0),
+ );

//material.colorNode = colorNode;
floor.material.colorNode = colorNode;
diff --git a/examples-testing/examples/webgpu_camera_logarithmicdepthbuffer.ts b/examples-testing/examples/webgpu_camera_logarithmicdepthbuffer.ts
index 2e0d37c..deac7ad 100644
--- a/examples-testing/examples/webgpu_camera_logarithmicdepthbuffer.ts
Expand Down
2 changes: 1 addition & 1 deletion examples-testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const files = {
'webgpu (wip)': [
'webgpu_backdrop',
'webgpu_backdrop_area',
// 'webgpu_backdrop_water',
'webgpu_backdrop_water',
'webgpu_camera_logarithmicdepthbuffer',
'webgpu_clearcoat',
// 'webgpu_compute_audio',
Expand Down
4 changes: 3 additions & 1 deletion examples-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "index.js",
"scripts": {
"create-examples": "node index.js",
"type-check": "tsc"
"type-check": "tsc",
"format": "prettier --write .",
"format-check": "prettier --check ."
},
"type": "module",
"author": "",
Expand Down
Loading