Revert "Move visibility range checking from the CPU to the GPU if NoCpuCulling is specified. (#23115)#24252
Merged
alice-i-cecile merged 3 commits intoMay 13, 2026
Conversation
…CpuCulling` is specified. (bevyengine#23115)" This reverts commit ebfbc3f.
Zeophlite
approved these changes
May 12, 2026
Contributor
|
I think this is the pragmatic choice |
JMS55
approved these changes
May 12, 2026
Contributor
JMS55
left a comment
There was a problem hiding this comment.
Yeah I think this is the right choice for 0.19.
Can we have a partial revert though? I think it makes sense to keep the code, but only enable it for non-shadow views. We can figure out how to pass directional light camera entities later, and what to do about point/spotlight shadows.
Contributor
Author
|
We chatted on Discord and will proceed with a full revert |
Member
|
@pcwalton I'm going to merge this now in the interest of shipping. |
pcwalton
added a commit
to pcwalton/bevy
that referenced
this pull request
May 14, 2026
Right now, visibility ranges are always resolved relative to the view. This is incorrect for shadow maps in two ways: 1. Visibility ranges for meshes in directional light shadow maps should be resolved relative to the camera that the cascades are associated with. 2. Visibility ranges for meshes in point and spot light shadow maps should be resolved relative to *some* camera. To properly solve (2), this commit introduces the notion of a *primary camera*. The primary camera is the one that visibility ranges are relative to, when rendering views not associated with any camera. Point and spot light shadow maps are currently not associated with a camera, and therefore we need this extra notion in order to properly evaluate visibility ranges. (As a follow-up, we should introduce the notion of *own shadow maps*, which will allow each camera to have separate shadow maps for point and spot lights. That feature is however out of scope for *this* patch, which simply seeks to make the existing semantics consistent.) A new component, `PrimaryCamera`, has been added, which allows the developer to customize which camera is primary. In the absence of this component, this PR implements a simple heuristic to determine the primary camera: to prefer cameras that render to a window. This heuristic should suffice in the vast majority of cases, so developers will rarely have to manually use the `PrimaryCamera` component. A new field, `lod_view_world_position`, has been added to `View` to supply the position of the primary camera to the GPU. This is much simpler than introducing a new uniform or using immediates, as bevyengine#24197 tried to do. This commit is the proper fix for bevyengine#23991. PR bevyengine#24252 attempted to fix this problem by reverting bevyengine#23115. However, this didn't actually fix the issue, because the semantics were still inconsistent. This commit constitutes the correct fix for the issue. I verified that, after un-reverting bevyengine#23115 on top of this patch and modifying it to use the new `lod_view_world_position`, that the issue reported in bevyengine#23991 disappears.
mgi388
pushed a commit
to mgi388/bevy
that referenced
this pull request
May 18, 2026
Right now, visibility ranges are always resolved relative to the view. This is incorrect for shadow maps in two ways: 1. Visibility ranges for meshes in directional light shadow maps should be resolved relative to the camera that the cascades are associated with. 2. Visibility ranges for meshes in point and spot light shadow maps should be resolved relative to *some* camera. To properly solve (2), this commit introduces the notion of a *shadow LOD origin*. The shadow LOD origin is the point that visibility ranges are relative to, when rendering views not associated with any camera. Point and spot light shadow maps are currently not associated with a camera, and therefore we need this extra notion in order to properly evaluate visibility ranges. (As a follow-up, we should introduce the notion of *own shadow maps*, which will allow each camera to have separate shadow maps for point and spot lights. That feature is however out of scope for *this* patch, which simply seeks to make the existing semantics consistent.) A new component, `ShadowLodOrigin`, has been added, which allows the developer to customize the shadow LOD origin. In the absence of this component, this PR implements a simple heuristic to determine the shadow LOD origin: to prefer an origin that coincides with cameras that render to a window. This heuristic should suffice in the vast majority of cases, so developers will rarely have to manually use the `ShadowLodOrigin` component. A new field, `lod_view_world_position`, has been added to `View` to supply the position of the shadow LOD origin to the GPU. This is much simpler than introducing a new uniform or using immediates, as bevyengine#24197 tried to do. This commit is the proper fix for bevyengine#23991. PR bevyengine#24252 attempted to fix this problem by reverting bevyengine#23115. However, this didn't actually fix the issue, because the semantics were still inconsistent. This commit constitutes the correct fix for the issue. I verified that, after un-reverting bevyengine#23115 on top of this patch and modifying it to use the new `lod_view_world_position`, that the issue reported in bevyengine#23991 disappears.
pull Bot
pushed a commit
to VitalyAnkh/bevy
that referenced
this pull request
May 19, 2026
…evyengine#24343) This PR undoes the revert of bevyengine#23115 that was done in bevyengine#24252. As part of doing so, it makes GPU-driven visibility range evaluation use the same semantics, introduced in bevyengine#24289, as CPU-driven visibility range evaluation. The first commit in this PR is the un-revert, and the second commit is the change to use the new machinery bevyengine#24289. This means that you can simply review the second commit (which is very short). To test, run the `visibility_range` example with `--no-cpu-culling`, and use the WASD keys to move behind the flight helmet and zoom out, while closely watching the shadow. Note that the shadow now properly reflects the LOD of the model.
mockersf
pushed a commit
to mockersf/bevy
that referenced
this pull request
May 21, 2026
Right now, visibility ranges are always resolved relative to the view. This is incorrect for shadow maps in two ways: 1. Visibility ranges for meshes in directional light shadow maps should be resolved relative to the camera that the cascades are associated with. 2. Visibility ranges for meshes in point and spot light shadow maps should be resolved relative to *some* camera. To properly solve (2), this commit introduces the notion of a *shadow LOD origin*. The shadow LOD origin is the point that visibility ranges are relative to, when rendering views not associated with any camera. Point and spot light shadow maps are currently not associated with a camera, and therefore we need this extra notion in order to properly evaluate visibility ranges. (As a follow-up, we should introduce the notion of *own shadow maps*, which will allow each camera to have separate shadow maps for point and spot lights. That feature is however out of scope for *this* patch, which simply seeks to make the existing semantics consistent.) A new component, `ShadowLodOrigin`, has been added, which allows the developer to customize the shadow LOD origin. In the absence of this component, this PR implements a simple heuristic to determine the shadow LOD origin: to prefer an origin that coincides with cameras that render to a window. This heuristic should suffice in the vast majority of cases, so developers will rarely have to manually use the `ShadowLodOrigin` component. A new field, `lod_view_world_position`, has been added to `View` to supply the position of the shadow LOD origin to the GPU. This is much simpler than introducing a new uniform or using immediates, as bevyengine#24197 tried to do. This commit is the proper fix for bevyengine#23991. PR bevyengine#24252 attempted to fix this problem by reverting bevyengine#23115. However, this didn't actually fix the issue, because the semantics were still inconsistent. This commit constitutes the correct fix for the issue. I verified that, after un-reverting bevyengine#23115 on top of this patch and modifying it to use the new `lod_view_world_position`, that the issue reported in bevyengine#23991 disappears.
mockersf
pushed a commit
to mockersf/bevy
that referenced
this pull request
May 21, 2026
…evyengine#24343) This PR undoes the revert of bevyengine#23115 that was done in bevyengine#24252. As part of doing so, it makes GPU-driven visibility range evaluation use the same semantics, introduced in bevyengine#24289, as CPU-driven visibility range evaluation. The first commit in this PR is the un-revert, and the second commit is the change to use the new machinery bevyengine#24289. This means that you can simply review the second commit (which is very short). To test, run the `visibility_range` example with `--no-cpu-culling`, and use the WASD keys to move behind the flight helmet and zoom out, while closely watching the shadow. Note that the shadow now properly reflects the LOD of the model.
mockersf
pushed a commit
that referenced
this pull request
May 21, 2026
Right now, visibility ranges are always resolved relative to the view. This is incorrect for shadow maps in two ways: 1. Visibility ranges for meshes in directional light shadow maps should be resolved relative to the camera that the cascades are associated with. 2. Visibility ranges for meshes in point and spot light shadow maps should be resolved relative to *some* camera. To properly solve (2), this commit introduces the notion of a *shadow LOD origin*. The shadow LOD origin is the point that visibility ranges are relative to, when rendering views not associated with any camera. Point and spot light shadow maps are currently not associated with a camera, and therefore we need this extra notion in order to properly evaluate visibility ranges. (As a follow-up, we should introduce the notion of *own shadow maps*, which will allow each camera to have separate shadow maps for point and spot lights. That feature is however out of scope for *this* patch, which simply seeks to make the existing semantics consistent.) A new component, `ShadowLodOrigin`, has been added, which allows the developer to customize the shadow LOD origin. In the absence of this component, this PR implements a simple heuristic to determine the shadow LOD origin: to prefer an origin that coincides with cameras that render to a window. This heuristic should suffice in the vast majority of cases, so developers will rarely have to manually use the `ShadowLodOrigin` component. A new field, `lod_view_world_position`, has been added to `View` to supply the position of the shadow LOD origin to the GPU. This is much simpler than introducing a new uniform or using immediates, as #24197 tried to do. This commit is the proper fix for #23991. PR #24252 attempted to fix this problem by reverting #23115. However, this didn't actually fix the issue, because the semantics were still inconsistent. This commit constitutes the correct fix for the issue. I verified that, after un-reverting #23115 on top of this patch and modifying it to use the new `lod_view_world_position`, that the issue reported in #23991 disappears.
mockersf
pushed a commit
that referenced
this pull request
May 21, 2026
…24343) This PR undoes the revert of #23115 that was done in #24252. As part of doing so, it makes GPU-driven visibility range evaluation use the same semantics, introduced in #24289, as CPU-driven visibility range evaluation. The first commit in this PR is the un-revert, and the second commit is the change to use the new machinery #24289. This means that you can simply review the second commit (which is very short). To test, run the `visibility_range` example with `--no-cpu-culling`, and use the WASD keys to move behind the flight helmet and zoom out, while closely watching the shadow. Note that the shadow now properly reflects the LOD of the model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This reverts commit ebfbc3f.
Objective
Solution
CurrentView/PointAndSpotLightShadowPrimaryCamera’s world position via Immediates for gpu vis range culling #24197 & Fix: Use the auxiliary entity (associated camera view)’s position viaViewUniformfor gpu visibility range culling #24133) I’ve put up are not satisfactory, and we need more time to come up with a good solution (i.e. post 0.19 rc) that:NoCpuCullingwill not undergo cpu visibility range culling. That was implemented in a separate PR: https://github.com/bevyengine/bevy/pull/23107/changes#diff-fec33d34072b7b4be336571ceecf2c10fc9bafd8366c1b29531089b7e3ef621cL745-L748. If you want to useVisibilityRangeculling, you will still need to have CPU culling enabled for the mesh.Testing
cargo run --example visibility_rangeworks normal now.