Fix SSAO flickering artifacts in cooked game (disable depth mips usage)
This commit is contained in:
BIN
Content/Shaders/SSAO.flax
(Stored with Git LFS)
BIN
Content/Shaders/SSAO.flax
(Stored with Git LFS)
Binary file not shown.
@@ -214,6 +214,7 @@ void AmbientOcclusionPass::Render(RenderContext& renderContext)
|
||||
return;
|
||||
PROFILE_GPU_CPU("Ambient Occlusion");
|
||||
|
||||
settings = ASSAO_Settings();
|
||||
settings.Radius = aoSettings.Radius * 0.006f;
|
||||
settings.ShadowMultiplier = aoSettings.Intensity;
|
||||
settings.ShadowPower = aoSettings.Power;
|
||||
@@ -296,8 +297,11 @@ void AmbientOcclusionPass::InitRTs(const RenderContext& renderContext)
|
||||
GPUTextureDescription tempDesc;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
// TODO: maybe instead of using whole mip chain request only SSAO_DEPTH_MIP_LEVELS?
|
||||
#if SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET < 99
|
||||
tempDesc = GPUTextureDescription::New2D((int32)m_halfSizeX, (int32)m_halfSizeY, 0, SSAO_DEPTH_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget | GPUTextureFlags::PerMipViews);
|
||||
#else
|
||||
tempDesc = GPUTextureDescription::New2D((int32)m_halfSizeX, (int32)m_halfSizeY, SSAO_DEPTH_FORMAT, GPUTextureFlags::ShaderResource | GPUTextureFlags::RenderTarget);
|
||||
#endif
|
||||
m_halfDepths[i] = RenderTargetPool::Get(tempDesc);
|
||||
RENDER_TARGET_POOL_SET_NAME(m_halfDepths[i], "SSAO.HalfDepth");
|
||||
}
|
||||
@@ -334,6 +338,7 @@ void AmbientOcclusionPass::UpdateCB(const RenderContext& renderContext, GPUConte
|
||||
const float farPlane = view.Far;
|
||||
const Matrix& proj = view.Projection;
|
||||
|
||||
Platform::MemoryClear(&_constantsBufferData, sizeof(_constantsBufferData));
|
||||
GBufferPass::SetInputs(view, _constantsBufferData.GBuffer);
|
||||
Matrix::Transpose(view.View, _constantsBufferData.ViewMatrix);
|
||||
|
||||
@@ -447,7 +452,7 @@ void AmbientOcclusionPass::PrepareDepths(const RenderContext& renderContext)
|
||||
}
|
||||
|
||||
// Only do mipmaps for higher quality levels (not beneficial on quality level 1, and detrimental on quality level 0)
|
||||
if (settings.QualityLevel > 1)
|
||||
if (settings.QualityLevel > 1 && SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET < 99)
|
||||
{
|
||||
for (int i = 1; i < SSAO_DEPTH_MIP_LEVELS; i++)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
// Config
|
||||
#define SSAO_DEPTH_MIP_LEVELS 4 // <- must match shader define
|
||||
#define SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET (99) // <- must match shader define
|
||||
#define SSAO_DEPTH_FORMAT PixelFormat::R16_Float
|
||||
#define SSAO_AO_RESULT_FORMAT PixelFormat::R8G8_UNorm
|
||||
#define SSAO_MAX_BLUR_PASS_COUNT 6
|
||||
|
||||
@@ -58,7 +58,7 @@ static const uint g_numTaps[4] = { 3, 5, 8, 12 };
|
||||
//
|
||||
#define SSAO_DETAIL_AO_ENABLE_AT_QUALITY_PRESET (1) // whether to use DetailAOStrength; to disable simply set to 99 or similar
|
||||
//
|
||||
#define SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET (2) // !!warning!! the MIP generation on the C++ side will be enabled on quality preset 2 regardless of this value, so if changing here, change the C++ side too
|
||||
#define SSAO_DEPTH_MIPS_ENABLE_AT_QUALITY_PRESET (99) // !!warning!! the MIP generation on the C++ side will be enabled on quality preset 2 regardless of this value, so if changing here, change the C++ side too
|
||||
#define SSAO_DEPTH_MIPS_GLOBAL_OFFSET (-4.3) // best noise/quality/performance tradeoff, found empirically
|
||||
//
|
||||
// !!warning!! the edge handling is hard-coded to 'disabled' on quality level 0, and enabled above, on the C++ side; while toggling it here will work for
|
||||
|
||||
Reference in New Issue
Block a user