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:
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+.
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);
If you are not sure what to set this value to, you can:
MetersToViewSpaceUnits is used internally
The greater the sharpness parameter, the more the blur preserves edges
Optionally, a larger blur sharpness can be used for a user-defined foreground depth range