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

Implement occlusion "soft-culling" to reduce LOD of occluded meshes rather than skipping drawing entirely #76297

Closed
wants to merge 2 commits into from

Conversation

myaaaaaaaaa
Copy link
Contributor

@myaaaaaaaaa myaaaaaaaaa commented Apr 20, 2023

Occlusion "soft-culling" has less noticeable artifacts (LOD popping) than standard "hard-culling" (disappearing/flickering meshes):

soft_cull.mp4

This opens the door for more aggressive occlusion settings, and allows meshes that wouldn't normally be considered candidates for acting as occluders (trees/vegetation, vents, rough/dirty windows, smoke and other particles, etc) to be made feasible for that purpose.

This puts a greater reliance on depth testing to prevent overshading (Hierarchical Z makes this very cheap for low polycounts) and HLOD/visibility ranges to reduce draw calls.

Adds three new project settings:

  • rendering/occlusion_culling/soft_cull_lod_bias
    LOD bias multiplier for occluded objects. 0 disables soft-culling (reverts to standard hard-culling)
comparison.mp4

Left: soft_cull_lod_bias = 0 (hard-culling)
Right: soft_cull_lod_bias = 0.05

  • rendering/occlusion_culling/bounds_scale
    Scale factor for occludee bounding boxes. Allows objects to be culled before they're fully occluded. Changing this is not recommended when hard-culling is active.
bounds_scale.mp4

Left: bounds_scale = 0.6
Right: bounds_scale = 0.1 (extreme value for demonstration purpose)

  • rendering/mesh_lod/lod_change/shadow_lod_bias
    LOD bias multiplier for shadow passes. This had to be separated out from the normal LOD bias to avoid shadow popping artifacts, so it was easier to just include it in this PR.

Depends on #74118, marked as draft until that one is merged

Fixes #53288
Fixes #63771
Fixes godotengine/godot-proposals#2600

@mrjustaguy
Copy link
Contributor

regarding culling, would make sense for lights to be able to turn of shadows if they're culled, that way they are much cheaper, reduce atlas usage and don't pop in (aside from shadows)

Shouldn't Shadow Lod Bias be under Mesh LOD if it's not Occlusion culling related?

@Calinou
Copy link
Member

Calinou commented Apr 20, 2023

Regarding shadow LOD bias, see also godotengine/godot-proposals#2600.

@myaaaaaaaaa
Copy link
Contributor Author

regarding culling, would make sense for lights to be able to turn of shadows if they're culled, that way they are much cheaper, reduce atlas usage and don't pop in (aside from shadows)

Disabling lights whose corresponding meshes have been soft-culled is out of scope for this PR. Hopefully, this basic implementation of soft-culling is performant enough to make additional optimizations unnecessary 🙂

Shouldn't Shadow Lod Bias be under Mesh LOD if it's not Occlusion culling related?

Yeah, I didn't really think these names through.

Should be fixed now.

@mrjustaguy
Copy link
Contributor

You misunderstood, I'm talking if the light's AABB is occluded, instead of it getting turned off, you just turn off it's shadow casting, to free up the Shadow Atlas, and reduce it's cost a little too, while reducing visual issues from hard culling.

@jcostello
Copy link
Contributor

What happen to this?

@Zireael07
Copy link
Contributor

myaaaaaa has been closing all of their PRs for some time already - no clue why

@AThousandShips AThousandShips removed this from the 4.x milestone Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment