bryanedds / Nu

Repository hosting the open-source Nu Game Engine and related projects.
MIT License
1.13k stars 156 forks source link

Software-Based Octnode Occlusion #518

Open bryanedds opened 1 year ago

bryanedds commented 1 year ago

Okay, here's what might work for pre-entity-render culling -

We could have special occluder entities whose AABB bounds are passed into the hierarchical octree queries that checks each bounds to see if the octnode is occluded by it. We already do frustum culls, so this just expands on that process.

We could also do some processing on the occluders to extend them into each other where they combine.

Alternative to extending occluders, we could software render the occluder bounds' to create an occlusion map that octnodes can be checked for occlusion with.

The important thing is that the occlusion checks happen on the octnodes rather than each individual entity that is pulled out of the octree.

I think the big question is, how do we get the occluders themselves efficiently? Maybe they should only be and affect enclosed entities? So we can just get them with a quicker enclosed frustum query on the octree?

bryanedds commented 1 year ago

Actual occlusion checks of each individual node might be done like so - See if node is entirely contained by occluder (easy case, but probably never actually happens). Else, see if all of the node's 6 non-center eye-facing vertices are inside all of the occluder's 6 non-center eye-facing vertices.

bryanedds commented 1 year ago

If the individual node occlusion check are too expensive, we can always just check the parent nodes instead of the leaf nodes.

bryanedds commented 1 year ago

Might be good to have different types of occluders, such as faces and OBBs rather than just AABBs.

bryanedds commented 1 year ago

Presumably need special in-editor rendering of occluders.

bryanedds commented 1 year ago

Might be good to have different types of occluders, such as faces and OBBs rather than just AABBs.

However, it might be better to just have one type of occluder: an oriented quad.

bryanedds commented 3 weeks ago

This type of fundamentally hard to solve problem might be better solved with a more general approach, such as this voxelizing occluder technology - https://medium.com/@Umbra3D/introduction-to-occlusion-culling-3d6cfb195c79

Another link from Umbra which seems to have little public presence - https://unity.com/blog/engine-platform/occlusion-culling-basics-unity-4-3

I don't know how available said software is to open source entities such as ourselves.

EDIT: this fellow also has an interesting approach - https://discussions.unity.com/t/released-perfect-culling-pixel-perfect-occlusion-culling/837404/422