NVIDIA HBAO+ 2.4.
Overview
HBAO+ is a SSAO algorithm designed to achieve high efficiency on DX11 GPUs.
The algorithm is based on HBAO [Bavoil and Sainz 2008], with the following differences:
- To minimize cache trashing, HBAO+ does not use any randomization texture. Instead, the algorithm uses an Interleaved Rendering approach, generating the AO in multiple passes with a unique jitter value per pass [Bavoil and Jansen 2013].
- To avoid over-occlusion artifacts, HBAO+ uses a simpler AO approximation than HBAO, similar to “Scalable Ambient Obscurance” [McGuire et al. 2012] [Bukowski et al. 2012].
- To minimize flickering, the HBAO+ is always rendered in full resolution, from full-resolution depths.
Package
doc/—this documentation page.
lib/—header file, import libraries and DLLs, for Win32, Win64 and Mac OS X.
samples/—source for sample applications demonstrating NVIDIA HBAO+.
Getting Started
INITIALIZE THE LIBRARY:
GFSDK_SSAO_CustomHeap CustomHeap;
CustomHeap.new_ = ::operator new;
CustomHeap.delete_ = ::operator delete;
GFSDK_SSAO_Status status;
GFSDK_SSAO_Context_D3D11* pAOContext;
status = GFSDK_SSAO_CreateContext_D3D11(pD3D11Device, &pAOContext, &CustomHeap);
assert(status == GFSDK_SSAO_OK); // HBAO+ requires feature level 11_0 or above
SET INPUT DEPTHS:
GFSDK_SSAO_InputData_D3D11 Input;
Input.DepthData.DepthTextureType = GFSDK_SSAO_HARDWARE_DEPTHS;
Input.DepthData.pFullResDepthTextureSRV = pDepthStencilTextureSRV;
Input.DepthData.ProjectionMatrix.Data = GFSDK_SSAO_Float4x4(pProjectionMatrix);
Input.DepthData.ProjectionMatrix.Layout = GFSDK_SSAO_ROW_MAJOR_ORDER;
Input.DepthData.MetersToViewSpaceUnits = SceneScale;
SET AO PARAMETERS:
GFSDK_SSAO_Parameters_D3D11 Params;
Params.Radius = 2.f;
Params.Bias = 0.1f;
Params.PowerExponent = 2.f;
Params.Blur.Enable = true;
Params.Blur.Radius = GFSDK_SSAO_BLUR_RADIUS_8;
Params.Blur.Sharpness = 4.f;
Params.Output.BlendMode = GFSDK_SSAO_OVERWRITE_RGB;
RENDER AO:
status = pAOContext->RenderAO(pD3D11Context, &Input, &Params, pOutputColorRTV);
assert(status == GFSDK_SSAO_OK);
Data Flow
MSAA Support
- If the input textures are MSAA then:
- If Output.MSAAMode is set to PER_PIXEL_AO, the library internally uses only sample0 and renders per-pixel AO (default & recommended path).
- If Output.MSAAMode is set to PER_SAMPLE_AO, the library does one full pass per MSAA subsample, which is effectively super-sampling the AO (slow path).
- In practice, we have found the PER_PIXEL_AO strategy to not cause any objectionable artifacts, even when using HBAO+ with TXAA.
HBAO+ Pipeline
CoarseAO & DetailAO
- Coarse AO
- For each pixel, 32 occlusion samples are taken in a variable-radius disk, with a minimum of 4 full-resolution pixels between the center pixel and the sample coordinates.
- This occlusion contribution is weighted by the CoarseAO parameter, and is always computed.
- Detail AO
- Optionally, 4 occlusion samples can be taken to the left/right/top/bottom of the center pixel, to capture close-range occlusion details.
- This occlusion contribution is weighted by the DetailAO parameter, and is skipped if DetailAO == 0.f.
Integration Time Estimates
- Initial integration (for a rendering engineer)
- <1 man-day with no input normals
- 1-2 man-days with input normals
- Initial parameter tuning
- <1 man-hour
- Tuning the parameter should be quick once the input data are correctly fed into the library
- The same HBAO+ parameters may be used globally across the whole game