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

LightProbeHelper: Add WebGPU version. #29301

Merged
merged 2 commits into from
Sep 3, 2024
Merged

LightProbeHelper: Add WebGPU version. #29301

merged 2 commits into from
Sep 3, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Sep 2, 2024

Related issue: #29295

Description

This PR adds a version of LightProbeHelper that is compatible with WebGPURenderer.

Copy link

github-actions bot commented Sep 2, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 685.1 kB
169.6 kB
685.1 kB
169.6 kB
+0 B
+0 B
WebGPU 821.7 kB
220.6 kB
821.7 kB
220.6 kB
-4 B
+5 B
WebGPU Nodes 821.3 kB
220.5 kB
821.3 kB
220.5 kB
+415 B
+99 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 461.9 kB
111.4 kB
461.9 kB
111.4 kB
+0 B
+0 B
WebGPU 522.1 kB
140.7 kB
522.1 kB
140.7 kB
-28 B
-3 B
WebGPU Nodes 478.8 kB
130.6 kB
478.8 kB
130.5 kB
-43.37 kB
-4 B

this.size = size;
this.type = 'LightProbeHelper';

this._intensity = intensity;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this property doing anything?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The uniform is updated in onBeforeRender().

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do see that, but why is the same "hack" not needed for the probe coefficients, but is needed for the intensity?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The line is indeed redundant. I'll remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The line is indeed redundant. I'll remove it.

This PR was working. Now it is not.

If you figure it out, please do your best to answer my question above so we will both understand. 🙏

Copy link
Collaborator Author

@Mugen87 Mugen87 Sep 3, 2024

Choose a reason for hiding this comment

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

I think there is a difference because intensity is a primitive value and _sh an array of objects. It probably would not work if you exchange the vector objects in the array and not just update their values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we can rewrite the intensity uniform like so:

const intensity = reference( 'intensity', 'float', lightProbe );

Then a manual uniform update isn't necessary. However, reference() would not work for uniform arrays ,afaik.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You added _sh in #29303, and that was not necessary if you are updating just the contents of the array.

With all due respect, I think you merged PRs too fast, without allowing time for the reviewer to respond.

Can you please continue to investigate this so we can all understand?

Copy link
Collaborator Author

@Mugen87 Mugen87 Sep 3, 2024

Choose a reason for hiding this comment

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

You added _sh in #29303, and that was not necessary if you are updating just the contents of the array.

I suspect you have tested this by just updating the existing vector objects, right? However, when the array is overwritten with new objects, the changes from #29303 are required.

I just wanted to be on the safe side, that's why I have honored the coefficients in #29303. If you think this is not required since the coefficient vectors are usually not overwritten with new instances, #29303 can be partly reverted.

With all due respect, I think you merged PRs too fast, without allowing time for the reviewer to respond.

I understand but it is also imported to move forward with the migration. We can fix such minor issues in dev as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

you have tested this by just updating the existing vector objects, right?

Right. Just the contents.

If you think this is not required since the coefficient vectors are usually not overwritten with new instances, #29303 can be partly reverted.

I think it's not required. Granted, it is a judgment call.

@sunag sunag added this to the r169 milestone Sep 2, 2024
@Mugen87 Mugen87 merged commit 6b2b479 into mrdoob:dev Sep 3, 2024
12 checks passed
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