Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MaskedOcclusionCulling.h File Reference

Masked Occlusion Culling. More...

Classes

class  MaskedOcclusionCulling
 
struct  MaskedOcclusionCulling::VertexLayout
 
struct  MaskedOcclusionCulling::ScissorRect
 
struct  MaskedOcclusionCulling::TriList
 
struct  MaskedOcclusionCulling::OcclusionCullingStatistics
 

Macros

#define QUICK_MASK   1
 
#define USE_D3D   1
 
#define PRECISE_COVERAGE   1
 
#define USE_AVX512   0
 
#define CLIPPING_PRESERVES_ORDER   1
 
#define ENABLE_STATS   0
 
#define MOC_RECORDER_ENABLE   0
 

Detailed Description

Masked Occlusion Culling.

General information

  • Input to all API functions are (x,y,w) clip-space coordinates (x positive left, y positive up, w positive away from camera). We entirely skip the z component and instead compute it as 1 / w, see next bullet. For TestRect the input is NDC (x/w, y/w).
  • We use a simple z = 1 / w transform, which is a bit faster than OGL/DX depth transforms. Thus, depth is REVERSED and z = 0 at the far plane and z = inf at w = 0. We also have to use a GREATER depth function, which explains why all the conservative tests will be reversed compared to what you might be used to (for example zMaxTri >= zMinBuffer is a visibility test)
  • We support different layouts for vertex data (basic AoS and SoA), but note that it's beneficial to store the position data as tightly in memory as possible to reduce cache misses. Big strides are bad, so it's beneficial to keep position as a separate stream (rather than bundled with attributes) or to keep a copy of the position data for the occlusion culling system.
  • The resolution width must be a multiple of 8 and height a multiple of 4.
  • The hierarchical Z buffer is stored OpenGL-style with the y axis pointing up. This includes the scissor box.
  • This code is only tested with Visual Studio 2015, but should hopefully be easy to port to other compilers.

Macro Definition Documentation

◆ CLIPPING_PRESERVES_ORDER

#define CLIPPING_PRESERVES_ORDER   1

Define CLIPPING_PRESERVES_ORDER to 1 to prevent clipping from reordering triangle rasterization order; This comes at a cost (approx 3-4%) but removes one source of temporal frame-to-frame instability.

◆ ENABLE_STATS

#define ENABLE_STATS   0

Define ENABLE_STATS to 1 to gather various statistics during occlusion culling. Can be used for profiling and debugging. Note that enabling this function will reduce performance significantly.

◆ MOC_RECORDER_ENABLE

#define MOC_RECORDER_ENABLE   0

Define MOC_RECORDER_ENABLE to 1 to enable frame recorder (see FrameRecorder.h/cpp for details)

◆ PRECISE_COVERAGE

#define PRECISE_COVERAGE   1

Define PRECISE_COVERAGE to 1 to more closely match GPU rasterization rules. The increased precision comes at a cost of slightly lower performance.

◆ QUICK_MASK

#define QUICK_MASK   1

Configure the algorithm used for updating and merging hierarchical z buffer entries. If QUICK_MASK is defined to 1, use the algorithm from the paper "Masked Software Occlusion Culling", which has good balance between performance and low leakage. If QUICK_MASK is defined to 0, use the algorithm from "Masked Depth Culling for Graphics Hardware" which has less leakage, but also lower performance.

◆ USE_AVX512

#define USE_AVX512   0

Define USE_AVX512 to 1 to enable experimental AVX-512 support. It's currently mostly untested and only validated on simple examples using Intel SDE. Older compilers may not support AVX-512 intrinsics.

◆ USE_D3D

#define USE_D3D   1

Configures the library for use with Direct3D (default) or OpenGL rendering. This changes whether the screen space Y axis points downwards (D3D) or upwards (OGL), and is primarily important in combination with the PRECISE_COVERAGE define, where this is important to ensure correct rounding and tie-breaker behaviour. It also affects the ScissorRect screen space coordinates.