Entity Culling Fabric/Forge

Entity Culling Fabric/Forge

138M Downloads

Does not cull block entities adjacent to a wall

LTCatt opened this issue ยท 4 comments

commented

Place chests against a wall.
Image

Then walk to the other side of the wall, and you'll notice that no block entities are culled.
Image

You need to place an additional wall, then SOME of the chests get culled.
Image

You have to get very close to the second wall to cull all 9 chests.
Image
Image


I looked into the code, and there might be two issues causing these problems.

https://github.com/LogisticsCraft/OcclusionCulling/blob/7a346eabc5edcfdef31df3c21202c3c1473fb506/src/main/java/com/logisticscraft/occlusionculling/OcclusionCullingInstance.java#L58
Using floor here instead of ceil might cause all AABBs to extend one block further than intended.

https://github.com/LogisticsCraft/OcclusionCulling/blob/7a346eabc5edcfdef31df3c21202c3c1473fb506/src/main/java/com/logisticscraft/occlusionculling/OcclusionCullingInstance.java#L397
The allowWallClipping check here likely prevents culling of block entities adjacent to a wall.

commented

To explain: many maps/builds depend on pushing stuff like armorstands into the ground, or have things poke through walls/floors. This gets worse when you start using custom models/resource packs/mods that add new blocks/entities.
So this is the intended behavior. Not doing that would be able to cause visual issues.
allowWallClipping is when the camera starts inside a wall, like in spectator mode/player stuck in blocks/f5 camera actually can slightly clip walls.
Changing the math there would deform the culling box. A chest (or any blockentitity for that matter) has a 3x3x3 culling box around it. If any block of that is visible (even when it's solid, like a wall), it will render the blockentity.

commented

Thank you for the explanation!
But under these limitation, could you consider adding a disabled-by-default config to allow more aggressive culling?
For example, in modpacks, culling at 1x1x1 instead of 3x3x3 could provide significant performance improvements. In my case, block entity rendering consumes 40% of the render thread time, and many of these could be culled safely.
But with the current algorithm, only ~15% of BEs get culled. It's way lower than my expectation.

Image

Even if issues arise with aggressive culling, modpack authors could handle them using blacklists. Therefore, adding this as a disabled-by-default config might be a good solution?

commented

That's 2 different things. 1x1x1 cull boxes would cause a lot of visible pop-in when walking around a corner.
Adding that it also checks if the final block is solid, and thereby cull directly behind 1 block thick walls would cause visual artifacting.
I could try with how bad this turns out, but I doubt it would make a huge performance difference, and look rather bad.

commented

Also, especially you are not on the latest version from yesterday, that blockentity count is garbage. It counted things that can't be culled like hoppers and comparator, since they are part of the world mesh.