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

WebGPURenderer: Shadows Performances Issues #30065

Open
RenaudRohlinger opened this issue Dec 8, 2024 · 5 comments
Open

WebGPURenderer: Shadows Performances Issues #30065

RenaudRohlinger opened this issue Dec 8, 2024 · 5 comments
Labels

Comments

@RenaudRohlinger
Copy link
Collaborator

RenaudRohlinger commented Dec 8, 2024

Description

Regarding the recent work on customCacheKey, lights, and shadows, is there a way to prevent renderShadow from calling renderObject.needsUpdate on every frame for every object?

In a moderately sized application, this check significantly impacts performance, causing a solid 30% drop (roughly 30–40 FPS). The check seems redundant, as we override the materials for the entire scene anyway.

If needed, this issue can likely be reproduced by enabling shadows in the webgpu_performance example.

Here’s a before/after comparison showing the impact of bypassing the cacheKey check for shadows:
Screenshot 2024-12-08 at 15 14 54

Screenshot 2024-12-08 at 15 08 45

With this hardcoded condition as a POC:
Screenshot 2024-12-08 at 15 08 45

The scene renders correctly as I believe the cacheKey check isn't needed anyway for shadows.

/cc @sunag @Mugen87.

@sunag
Copy link
Collaborator

sunag commented Dec 8, 2024

Regarding the recent work on customCacheKey, lights, and shadows, is there a way to prevent renderShadow from evaluating renderObject.initialCacheKey !== renderObject.getCacheKey() on every frame for every object?

I'm curious why it's testing cacheKey every frame and every object, this shouldn't happen. I just opened webgpu_backdrop_water and this process wasn't executed once.

@RenaudRohlinger
Copy link
Collaborator Author

Example in webgpu_shadowmap_csm:
image

@sunag
Copy link
Collaborator

sunag commented Dec 8, 2024

Same thing, I even put a console.log() to test, not shown once.

image

image

@RenaudRohlinger
Copy link
Collaborator Author

RenaudRohlinger commented Dec 8, 2024

Ah indeed my bad the similar name between renderObject.getCacheKey and nodes.getCacheKey was missleading me! It's because the performance issue comes from renderObject.needsUpdate in the if condition just before your log, so never reaches renderObject.initialCacheKey !== renderObject.getCacheKey().

Could be this condition forcing the cacheKey to be update every frame?

if ( this.object.receiveShadow ) {

	cacheKey += 1;

}
image image

Repository owner deleted a comment from yuvashrikarunakaran Dec 16, 2024
Repository owner deleted a comment from Danilkat Dec 16, 2024
@Mugen87 Mugen87 added the WebGPU label Dec 16, 2024
@Samsy
Copy link
Contributor

Samsy commented Dec 19, 2024

Having same huge perfs issues when rendering shadow, a lot of cachekeys fetch

Screenshot 2024-12-19 at 15 50 05

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

No branches or pull requests

4 participants