Skip to content

WebGPURenderer: Introduce ProjectorLight #31022

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

Merged
merged 10 commits into from
Apr 30, 2025
Merged

WebGPURenderer: Introduce ProjectorLight #31022

merged 10 commits into from
Apr 30, 2025

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Apr 28, 2025

Related issue: #31020 (comment)

Description

Based on the @N8python PR (#24589) and @WestLangley and @Mugen87 conversations, it introduces ProjectorLight to WebGPURenderer allowing the use of .map and TSL functions for procedural effects like the caustic effect in the demo below.

Live demo

projectorLight = new THREE.ProjectorLight( 0xffffff, 100 );
projectorLight.colorNode = Fn( ( [ projectorUV ] ) => {

	const waterLayer0 = mx_worley_noise_float( projectorUV.mul( 10 ).add( time ) );
	const waterLayer1 = mx_worley_noise_float( projectorUV.mul( 5 ).add( time ) );

	const caustic = waterLayer0.mul( waterLayer1 ).mul( color( 0x5abcd8 ) ).mul( 2 );

	return caustic;

} );

image

** Summary **

Copy link

github-actions bot commented Apr 28, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.33
78.33
336.33
78.33
+0 B
+0 B
WebGPU 547.85
151.9
548.77
152.17
+924 B
+265 B
WebGPU Nodes 547.2
151.74
548.12
152.01
+924 B
+264 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 466.15
112.56
466.15
112.56
+0 B
+0 B
WebGPU 623.1
168.69
623.98
168.91
+882 B
+228 B
WebGPU Nodes 577.97
157.98
578.85
158.2
+882 B
+220 B

@WestLangley
Copy link
Collaborator

ProjectorLight should probably have its own ProjectorLightHelper since SpotLightHelper is conical.

@mrdoob mrdoob added this to the r177 milestone Apr 30, 2025
@sunag sunag merged commit 6224432 into mrdoob:dev Apr 30, 2025
12 checks passed
@sunag sunag deleted the dev-projector branch April 30, 2025 16:12
@mrdoob
Copy link
Owner

mrdoob commented May 1, 2025

Considering that we have RectAreaLight, shouldn't we call it RectLight? 🤔

@mrdoob
Copy link
Owner

mrdoob commented May 2, 2025

@sunag
Copy link
Collaborator Author

sunag commented May 2, 2025

I don't have a strong opinion on this if you prefer to change it. But I believe that the RectLight in other renderers is the equivalent of RectAreaLight and not the current ProjectorLight.

@WestLangley
Copy link
Collaborator

ProjectorLight is akin to a movie projector. Hence the name.

@mrdoob
Copy link
Owner

mrdoob commented May 3, 2025

Yes I understand that...

But SpotLight also has a map and it could also be thought of a projector with a mask...

How about we add a new property to SpotLight instead?

light.shape = THREE.RectShape;

That would open the door for more shapes without resulting in more API/docs work.

Same for RectAreaLight, we could rename it to AreaLight and add a shape property so in the future we could add support for CircleShape, etc

RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* Texture: Introduce `width`, `height`, `depth`

* Fix `lightShadowMatrix()` if `renderer.shadowMap.enabled` is `false`

* Remove `spotLight.attenuationNode`

* Introduce `ProjectorLight`

* add `webgpu_lights_projector` example

* Update webgpu_lights_projector.jpg

* improve cache key

* optimize for mobile

* Update webgpu_lights_projector.jpg
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* Texture: Introduce `width`, `height`, `depth`

* Fix `lightShadowMatrix()` if `renderer.shadowMap.enabled` is `false`

* Remove `spotLight.attenuationNode`

* Introduce `ProjectorLight`

* add `webgpu_lights_projector` example

* Update webgpu_lights_projector.jpg

* improve cache key

* optimize for mobile

* Update webgpu_lights_projector.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants