Skip to content

SpotLightShadow: Introduce aspect property#31020

Merged
sunag merged 6 commits into
mrdoob:devfrom
sunag:dev-improve-spotlight
Apr 28, 2025
Merged

SpotLightShadow: Introduce aspect property#31020
sunag merged 6 commits into
mrdoob:devfrom
sunag:dev-improve-spotlight

Conversation

@sunag

@sunag sunag commented Apr 28, 2025

Copy link
Copy Markdown
Collaborator

@sunag sunag marked this pull request as ready for review April 28, 2025 16:40
@sunag sunag added this to the r177 milestone Apr 28, 2025
Comment thread examples/webgpu_lights_spotlight.html Fixed
@github-actions

github-actions Bot commented Apr 28, 2025

Copy link
Copy Markdown

📦 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.81
151.88
547.81
151.89
+4 B
+1 B
WebGPU Nodes 547.16
151.73
547.16
151.73
+4 B
+1 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.78
112.28
465.78
112.28
+0 B
+0 B
WebGPU 622.66
168.44
622.7
168.46
+30 B
+11 B
WebGPU Nodes 577.54
157.71
577.57
157.72
+30 B
+14 B

@WestLangley

Copy link
Copy Markdown
Collaborator

I think the aspect should be automatic: set to 1 if there is no texture, and equal to the texture's aspect otherwise. There is no need for a separate aspect property.

@sunag

sunag commented Apr 28, 2025

Copy link
Copy Markdown
Collaborator Author

I think the aspect should be automatic: set to 1 if there is no texture, and equal to the texture's aspect otherwise. There is no need for a separate aspect property.

I think it could be useful for rectangular lighting.

@WestLangley

Copy link
Copy Markdown
Collaborator

I think it could be useful for rectangular lighting.

I do not think that is necessary.

@WestLangley

Copy link
Copy Markdown
Collaborator

Also, I think a rectangular projection is a bit too complex to ask a user to implement themselves in TSL, and it should be a built-in feature like "focus" and "penumbra".

Support for "cookies" would also be a reasonable built-in feature for a spotlight.

@sunag

sunag commented Apr 28, 2025

Copy link
Copy Markdown
Collaborator Author

Support for "cookies" would also be a reasonable built-in feature for a spotlight.

What would be support for cookies?

@WestLangley

Copy link
Copy Markdown
Collaborator

What would be support for cookies?

Here is a good explanation: https://docs.unity3d.com/Manual/Cookies-introduction.html.

@WestLangley

Copy link
Copy Markdown
Collaborator

TSL is great. However, I do not see it as the best solution for the "projector light" use case. Users should not have to code this particular feature themselves, IMHO.

@sunag

sunag commented Apr 28, 2025

Copy link
Copy Markdown
Collaborator Author

Here is a good explanation: https://docs.unity3d.com/Manual/Cookies-introduction.html.

It seems like the article is talking about shadow baking like this and light.map features, but maybe there's something more there?

The idea of ​​a projector is interesting especially if we integrate it with a light.colorNode.

@sunag

sunag commented Apr 28, 2025

Copy link
Copy Markdown
Collaborator Author

I'm going to merge this PR and will work on creating a ProjectorLight that supports procedural shader, it seems like a good opportunity.

@sunag sunag merged commit 8ee79cf into mrdoob:dev Apr 28, 2025
@sunag sunag deleted the dev-improve-spotlight branch April 28, 2025 18:14
@WestLangley

Copy link
Copy Markdown
Collaborator

Cookies can have an alpha channel, which can be used to attenuate the intensity.

Here is another example: https://developer.playcanvas.com/tutorials/light-cookies/

I'm going to merge this PR and will work on creating a ProjectorLight

A projector light that projects a movie would be good. It should just work, without the user have to write TSL to make it work.

RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* TSL: Fix convert `.set*()` value to node-object

* SpotLightShadow: Introduce `aspect`

* improve custom aspect example

* cleanup

* Update webgpu_lights_spotlight.html

* Update webgpu_lights_spotlight.html
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* TSL: Fix convert `.set*()` value to node-object

* SpotLightShadow: Introduce `aspect`

* improve custom aspect example

* cleanup

* Update webgpu_lights_spotlight.html

* Update webgpu_lights_spotlight.html
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