Fix: Send CurrentView/ PointAndSpotLightShadowPrimaryCamera ’s world position via Immediates for gpu vis range culling#24197
Conversation
JMS55
left a comment
There was a problem hiding this comment.
Note: With this PR, we lose out on PreprocessingOnly support for WebGPU, until immediates are added to the spec and wgpu supports it.
|
I will add a marker component for the camera to use for gpu vis culling spot and point lights shadows, that should be ready to review in a few hours |
34ad77f to
3a800cd
Compare
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
a767075 to
3f8e38b
Compare
3f8e38b to
ac87f8e
Compare
CurrentView/ an ExtractedCamera’s world position via immediates for gpu vis range cullingCurrentView/ PointAndSpotLightShadowPrimaryCamera ’s world position via Immediates for gpu vis range culling
|
I'm not sure if PointAndSpotLightShadowPrimaryCamera is correct. The original implementation #12916 says:
|
|
Thanks for finding that @beicause My thoughts given that information:
I’ll get to implementing this logic in about 18 hours unless there are any objections (and may work on it sooner if I get some timely affirmations) |
|
IMO we should consider reverting #23115. This may introduce extra overhead on GPU and regression on WebGPU before immediates is supported.
bevy/crates/bevy_light/src/lib.rs Line 429 in 2002a18 |
Seems seems quite expensive 😬 . Also I don't know what that would even look like, I feel like the shadows would be all weird. |
I agree that it would look weird 😢 I’m not sure how to interpret the original intent for visibility ranges in this context then...
Reverting is definitely an option at this point… I’ll just keep this PR as is for now. Thanks for the quick input! |
| } else { | ||
| // There is no single designated primary camera to use for vis range culling of the shadows. | ||
| // Do not render them. | ||
| continue; |
There was a problem hiding this comment.
Doesn't this continue skip the entire preprocess dispatch for the view?
There was a problem hiding this comment.
For the PointLight/SpotLight shadow view, yes
But I would consider that a user configuration error at this point, so the shadows just wouldn’t be rendered.
(However we do not need to continue this conversation because I will close this PR! It seems the consensus is converging on reverting the offending PR)
Objective
ViewUniformfor gpu visibility range culling #24133 . Decisions made can be mixed and matched between the two, just let me knowImmediatesto avoid bloatingViewUniforms. There was also a concern about usingRetainedViewEntityto pass information about what camera to use along. This is that alternate implementation path.Solution
CurrentViewmechanism to get the current view’s world position, used when preprocessing directional light shadow views. This will be used for gpu vis range culling dir light shadows.RootNonCameraViews), a marker component has been added to denote the camera to use:PointAndSpotLightShadowPrimaryCamera. There must only be one camera with this component. This camera’s position will be used for gpu vis range culling point/spotlight shadows.PointAndSpotLightShadowPrimaryCameracomponent, we can revertac87f8e — the previous logic just queried for extracted cameras and took the world position of the first one returned by the query.
Note
Copying this comment from @JMS55:
With this PR, we lose out on PreprocessingOnly support for WebGPU, until immediates are added to the spec and wgpu supports it.
Testing
cargo run --example visibility_range -- --no-cpu-cullingworks with a directional light as desiredvisibility_rangeexample to be a Spot or PointLight like so:And added the
PointAndSpotLightShadowPrimaryCamerato theCamera3din the example, and then ran the example. The shadows of spot and point lights also look normal.