Skip to content

Examples: Add webgpu_reflection_blurred #31116

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 12 commits into from
May 15, 2025
Merged

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented May 15, 2025

Related issue: #31110, #31114, #31115

Description

Live example

Add webgpu_reflection_blurred example.

image

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 337.26
78.64
337.26
78.64
+0 B
+0 B
WebGPU 549.9
152.44
549.9
152.44
+0 B
+0 B
WebGPU Nodes 549.25
152.29
549.25
152.29
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 467.34
112.95
467.34
112.95
+0 B
+0 B
WebGPU 624.5
169.06
624.5
169.06
+0 B
+0 B
WebGPU Nodes 579.35
158.35
579.35
158.35
+0 B
+0 B

@sunag sunag added this to the r177 milestone May 15, 2025
@sunag sunag marked this pull request as ready for review May 15, 2025 07:27
@sunag sunag merged commit abf99f5 into mrdoob:dev May 15, 2025
11 checks passed
const roughness = uniform( .9 );
const radius = uniform( 0.2 );

const reflection = reflector( { resolution: 1, depth: true, bounces: false } ); // 0.5 is half of the rendering view
Copy link
Collaborator

@Mugen87 Mugen87 May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example looks awesome!

The only thing I would suggest to change is the default resolution of the reflector. On my macMini M2 Pro, the current example runs around 30 FPS. Using the half resolution for the reflection, the frame rate is back to 60 FPS. Since the reflections are blurred, you barely see a difference in quality anyway (mostly at the plane with the uv texture).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we set resolution to 0.5 on a non-retina screen the reflection becomes pixelated:

Screenshot 2025-05-16 at 5 04 41 PM

Instead of 0.5 maybe something like 1 / devicePixelRatio would work better?

@mrdoob
Copy link
Owner

mrdoob commented May 15, 2025

Feels like there are some premultiply related issues in the blurred edges.

The inverted image makes it easier to see:

image

@sunag
Copy link
Collaborator Author

sunag commented May 15, 2025

Feels like there are some premultiply related issues in the blurred edges.

I'm not sure I understand, it's intentional that the blur expands beyond the edges.

@sunag sunag deleted the dev-reflection-blurred branch May 15, 2025 14:56
@ektogamat
Copy link

Congratulations and thank you so much for this. It is super awesome 🎉!

@mrdoob
Copy link
Owner

mrdoob commented May 16, 2025

@sunag

Feels like there are some premultiply related issues in the blurred edges.

I'm not sure I understand, it's intentional that the blur expands beyond the edges.

There's a black glow happening in the blur.

Screenshot 2025-05-16 at 5 19 52 PM

Setting reflectionIntensity to 1 improves things but there's still black glow at the top.:

Screenshot 2025-05-16 at 5 22 00 PM

So it seems to be something related to premultiply compositing.

For comparison, I tried creating a similar scene in https://threejs.org/editor/ and used the realistic/pathtracer to render it:

Screenshot 2025-05-16 at 5 27 16 PM

RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* fix clear texture and facing away if `bounce` is `false`

* add `premult`, `unpremult`

* cleanup

* add `hashBlur` options { mask, premultipliedAlpha }

* add docs and cleanup

* add `webgpu_reflection_blurred` example

* update webgpu_reflection_blurred

* update webgpu_reflection_blurred

* Update webgpu_reflection_blurred.html
RuthySheffi pushed a commit to RuthySheffi/three.js that referenced this pull request Jun 5, 2025
* fix clear texture and facing away if `bounce` is `false`

* add `premult`, `unpremult`

* cleanup

* add `hashBlur` options { mask, premultipliedAlpha }

* add docs and cleanup

* add `webgpu_reflection_blurred` example

* update webgpu_reflection_blurred

* update webgpu_reflection_blurred

* Update webgpu_reflection_blurred.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.

4 participants