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

ReflectorNode: Add getDepthNode(). #29621

Merged
merged 2 commits into from
Oct 11, 2024
Merged

ReflectorNode: Add getDepthNode(). #29621

merged 2 commits into from
Oct 11, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Oct 11, 2024

Related issue: -

Description

A common use case with mirrors is to create faded reflections via some sort of distance attenuation, see https://discourse.threejs.org/t/creating-a-fading-reflection/3831.

This PR introduces a new constructor parameter depth. When set to true, the depth information of the reflection pass is saved into a depth texture.

It's then possible to query a depth texture node via getDepthNode(). Since ReflectorNode supports multiple virtual cameras, it's required to pass the current camera used for rendering to select the correct depth node.

@sunag Do you think this API goes in the right direction?

Copy link

github-actions bot commented Oct 11, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 689.92
170.93
689.92
170.93
+0 B
+0 B
WebGPU 814.17
219.22
814.71
219.35
+537 B
+132 B
WebGPU Nodes 813.68
219.06
814.22
219.22
+537 B
+163 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 462.94
111.81
462.94
111.81
+0 B
+0 B
WebGPU 537.52
145.03
537.56
145.04
+37 B
+3 B
WebGPU Nodes 493.64
134.76
493.67
134.77
+37 B
+7 B

@sunag sunag added this to the r170 milestone Oct 11, 2024
@sunag sunag marked this pull request as ready for review October 11, 2024 15:02
@sunag
Copy link
Collaborator

sunag commented Oct 11, 2024

Coincidentally I was thinking of something like this, but without the reflector. I made a change so that we don't need the camera as a parameter.

image

@sunag sunag merged commit 09a6807 into mrdoob:dev Oct 11, 2024
12 checks passed
@mrdoob
Copy link
Owner

mrdoob commented Oct 11, 2024

@Mugen87 Should a example use this? May go unnoticed otherwise.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Oct 12, 2024

Definitely. Just wanted to go ahead and add getDepthNode() for devs who want a replacement for ReflectorForSSRPass. This module is like reflector but with distance attenuation support. When developers can at least request the depth from ReflectorNode, they can built a custom solution until we provide a bit more API. Maybe adding getLinearDepthNode() would also be a good idea since otherwise the camera handling on app level is a bit tricky (you would need the internal virtual camera for this).

I'm still unsure about the API and the kind of internal solution. E.g. ReflectorNode could have a fade and maxDistance property but this is maybe too specific.

@sunag
Copy link
Collaborator

sunag commented Oct 13, 2024

wip tiled lighting.

image

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