Keywords: Graphics, Rendering, Occlusion Culling, Depth Testing, Hierarchial Z-Buffer, HZB, Early Z

Depth Testing

Documents

Depth testing - OpenGL
https://learnopengl.com/Advanced-OpenGL/Depth-testing

Stencil testing - OpenGL
https://learnopengl.com/Advanced-OpenGL/Stencil-testing

Hierarchial Z-Buffer Occlusion

Principle of HZB Occlusion

Origin: Performance boost on UE4 games for Radeon users - guru3d
HZB Occlusion is a technique supposed to increase performance is a method of rasterizing certain portions of a scene into a depth buffer and then performing image-space occlusion queries on a hierarchical structure constructed from the depth buffer. In any realistic 3D scene, there are things you can see and things that you can’t see. It sounds simple, but the application of this knowledge can have very beneficial effects on the performance of an application billed with rendering the 3D scene in real time. Generally, we want to lower the computational cost of objects that do not contribute to the scene - those objects that are outside our field of view or are obscured by other objects. The Z-buffer is the last stage in the rendering pipeline where an object can be identified as “invisible”; in this case, the object in question is a fragment, and it can only be identified as invisible when the fragment’s depth value is “deeper” than something that has already been rendered at the same raster position. The Z-buffer test is invoked for each and every fragment of a higher-level object being rendered - the polygonal representation of a “thing” in the scene, such as a person, a wall, a car, etc - and thus imposes a rather high computational cost of visibility determination, even with recent optimizations made to hardware z-buffer mechanisms.

Occlusion Culling for UE4 games

Origin: Performance boost on UE4 games for Radeon users - guru3d

This is a simple command that can increase performance by a decent margin, in UE4 games, for Radeon users. All we have to do is open the respective engine.ini for each game and add these lines.

[/script/engine.renderersettings]
r.HZBOcclusion=1

A lot of games using UE4, have this setting at “0”. The reason is probably because this setting at “1” causes a 10% performance loss on NVidia hardware.
So if you are using NVidia, make sure this setting is at “0”. And if you are using AMD, make sure it’s set to “1”.
Ideally, all games would have this setting exposed for each user to decided. Or have some script that would detect an AMD or NVidia GPU and set the value accordingly.
So far, the only game I found that has this option in-game is Supraland Six Feet Under.
Performance gains vary with game and scene, but I tested in a couple of games and found these gains.
High on Life: 7%
Supraland SIU: 12%

Blogs of HZBO

Hierarchical Z-Buffer Occlusion Culling
https://www.nickdarnell.com/hierarchical-z-buffer-occlusion-culling/

Hierarchical-Z map based occlusion culling
http://rastergrid.com/blog/2010/10/hierarchical-z-map-based-occlusion-culling/

Research Papers

Image Space Occlusion Culling Image Space Occlusion Culling
http://www.cs.tau.ac.il/~dcor/Graphics/adv-slides/short-image-based-culling.pdf

Space-Time Hierarchical Occlusion Culling for Micropolygon Rendering with Motion Blur
http://graphics.stanford.edu/papers/tzpyramid/tzpyramid.pdf

Visibility Culling using Hierarchical Occlusion Maps
https://www.cs.drexel.edu/~david/Classes/Papers/p77-zhang.pdf

Hierarchical Z-Buffer Visibility
https://www.cs.princeton.edu/courses/archive/spring01/cs598b/papers/greene93.pdf

Visibility and Occlusion Culling
https://www.cs.purdue.edu/homes/aliaga/cs535-14/lec-visibility.pdf

Visibility Culling
http://www.cse.ohio-state.edu/~hwshen/788/sp01/Culling.ppt

Examples

Software Occlusion Culling

A State-of-the-art (fastest) Software Occlusion ulling System (Recommended)
https://github.com/rawrunprotected/rasterizer

OpenGL

OpenGL sample for shader-based occlusion culling
https://github.com/nvpro-samples/gl_occlusion_culling

Vulkan Conditional Rendering

Vulkan conditional rendering
https://www.saschawillems.de/blog/2018/09/05/vulkan-conditional-rendering/


如果有天堂,应该是图书馆的模样。 -豪尔赫·路易斯·博尔赫斯