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

Lensflare: Add WebGPU version. #1272

Merged
merged 4 commits into from
Sep 25, 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
36 changes: 34 additions & 2 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7354,7 +7354,7 @@ index c8bce4bf..a28a7f00 100644

loader.load(`textures/equirectangular/spruit_sunrise_${resolution}.hdr.jpg`, function (texture) {
diff --git a/examples-testing/examples/webgl_loader_tilt.ts b/examples-testing/examples/webgl_loader_tilt.ts
index 2a583c2b..8e3e976b 100644
index 843b3cfd..ea737c79 100644
--- a/examples-testing/examples/webgl_loader_tilt.ts
+++ b/examples-testing/examples/webgl_loader_tilt.ts
@@ -3,7 +3,7 @@ import * as THREE from 'three';
Expand Down Expand Up @@ -9944,7 +9944,7 @@ index ecc9b28e..2e894236 100644
init();

diff --git a/examples-testing/examples/webgl_postprocessing_advanced.ts b/examples-testing/examples/webgl_postprocessing_advanced.ts
index adaef620..2b43e46a 100644
index 82fc39be..1a14c2b9 100644
--- a/examples-testing/examples/webgl_postprocessing_advanced.ts
+++ b/examples-testing/examples/webgl_postprocessing_advanced.ts
@@ -21,11 +21,21 @@ import { GammaCorrectionShader } from 'three/addons/shaders/GammaCorrectionShade
Expand Down Expand Up @@ -13622,6 +13622,38 @@ index cfd72172..ae3271f9 100644
}

renderer.render(scene, camera);
diff --git a/examples-testing/examples/webgpu_lensflares.ts b/examples-testing/examples/webgpu_lensflares.ts
index 40478039..0abdb8f1 100644
--- a/examples-testing/examples/webgpu_lensflares.ts
+++ b/examples-testing/examples/webgpu_lensflares.ts
@@ -1,14 +1,14 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';

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

import { FlyControls } from 'three/addons/controls/FlyControls.js';
import { LensflareMesh, LensflareElement } from 'three/addons/objects/LensflareMesh.js';

-let container, stats;
+let container: HTMLDivElement, stats: Stats;

-let camera, scene, renderer;
-let controls;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;
+let controls: FlyControls;

const clock = new THREE.Clock();

@@ -73,7 +73,7 @@ function init() {
addLight(0.08, 0.8, 0.5, 0, 0, -1000);
addLight(0.995, 0.5, 0.9, 5000, 5000, -1000);

- function addLight(h, s, l, x, y, z) {
+ function addLight(h: number, s: number, l: number, x: number, y: number, z: number) {
const light = new THREE.PointLight(0xffffff, 1.5, 2000, 0);
light.color.setHSL(h, s, l);
light.position.set(x, y, z);
diff --git a/examples-testing/examples/webgpu_lightprobe.ts b/examples-testing/examples/webgpu_lightprobe.ts
index 66f9ffcb..0bcfb599 100644
--- a/examples-testing/examples/webgpu_lightprobe.ts
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 53 files
+34 −24 build/three.cjs
+34 −24 build/three.module.js
+1 −1 build/three.module.min.js
+219 −55 build/three.webgpu.js
+1 −1 build/three.webgpu.min.js
+219 −55 build/three.webgpu.nodes.js
+1 −1 build/three.webgpu.nodes.min.js
+14 −0 docs/api/en/math/Triangle.html
+9 −0 docs/api/en/objects/BatchedMesh.html
+5 −5 docs/manual/ar/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/en/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/fr/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/it/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/ja/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/ko/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/pt-br/introduction/How-to-create-VR-content.html
+5 −5 docs/manual/zh/introduction/How-to-create-VR-content.html
+4 −0 docs/page.css
+1 −0 examples/files.json
+32 −12 examples/jsm/controls/TrackballControls.js
+9 −6 examples/jsm/loaders/ColladaLoader.js
+3 −1 examples/jsm/loaders/DRACOLoader.js
+12 −9 examples/jsm/loaders/FBXLoader.js
+10 −7 examples/jsm/loaders/KTX2Loader.js
+4 −3 examples/jsm/loaders/MTLLoader.js
+29 −10 examples/jsm/loaders/MaterialXLoader.js
+5 −3 examples/jsm/loaders/OBJLoader.js
+5 −4 examples/jsm/loaders/PCDLoader.js
+3 −2 examples/jsm/loaders/PDBLoader.js
+8 −5 examples/jsm/loaders/PLYLoader.js
+3 −2 examples/jsm/loaders/STLLoader.js
+3 −1 examples/jsm/loaders/TiltLoader.js
+10 −10 examples/jsm/loaders/VRMLLoader.js
+4 −3 examples/jsm/loaders/VTKLoader.js
+3 −2 examples/jsm/loaders/XYZLoader.js
+322 −0 examples/jsm/objects/LensflareMesh.js
+ examples/screenshots/webgl_loader_tilt.jpg
+ examples/screenshots/webgl_postprocessing_advanced.jpg
+ examples/screenshots/webgpu_lensflares.jpg
+2 −5 examples/webgl_loader_tilt.html
+2 −2 examples/webgl_postprocessing_advanced.html
+9 −1 examples/webgpu_compute_sort_bitonic.html
+186 −0 examples/webgpu_lensflares.html
+2 −2 examples/webgpu_occlusion.html
+24 −0 src/math/Triangle.js
+1 −0 src/nodes/TSL.js
+15 −0 src/nodes/accessors/StorageBufferNode.js
+99 −0 src/nodes/gpgpu/AtomicFunctionNode.js
+23 −10 src/objects/BatchedMesh.js
+1 −0 src/objects/Line.js
+7 −23 src/objects/Mesh.js
+2 −0 src/objects/Points.js
+2 −1 src/renderers/webgpu/nodes/WGSLNodeBuilder.js
22 changes: 13 additions & 9 deletions types/three/examples/jsm/objects/Lensflare.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { Color, Mesh, Texture } from "three";

export class LensflareElement {
constructor(texture: Texture, size?: number, distance?: number, color?: Color);
declare class Lensflare extends Mesh {
readonly isLensflare: true;

constructor();

addElement: (element: LensflareElement) => void;
dispose: () => void;
}

declare class LensflareElement {
texture: Texture;
size: number;
distance: number;
color: Color;
}

export class Lensflare extends Mesh {
constructor();
readonly isLensflare: true;

addElement(element: LensflareElement): void;
dispose(): void;
constructor(texture: Texture, size?: number, distance?: number, color?: Color);
}

export { Lensflare, LensflareElement };
21 changes: 21 additions & 0 deletions types/three/examples/jsm/objects/LensflareMesh.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Color, Mesh, Texture } from "three";

declare class LensflareMesh extends Mesh {
readonly isLensflare: true;

constructor();

addElement: (element: LensflareElement) => void;
dispose: () => void;
}

declare class LensflareElement {
texture: Texture;
size: number;
distance: number;
color: Color;

constructor(texture: Texture, size?: number, distance?: number, color?: Color);
}

export { LensflareElement, LensflareMesh };
Loading