From 0af9b99488f51567ff8385d499bb420ccd9257ec Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 17 Oct 2024 04:42:17 -0700 Subject: [PATCH] HnTaskManager: added comments about depth bias computation --- Hydrogent/src/Tasks/HnTaskManager.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Hydrogent/src/Tasks/HnTaskManager.cpp b/Hydrogent/src/Tasks/HnTaskManager.cpp index 05404532..6338b086 100644 --- a/Hydrogent/src/Tasks/HnTaskManager.cpp +++ b/Hydrogent/src/Tasks/HnTaskManager.cpp @@ -270,7 +270,20 @@ void HnTaskManager::CreateRenderShadowsTask(const HnShadowMapManager& ShadowMapM TaskParams.State.DepthBiasEnabled = true; TaskParams.State.SlopeScaledDepthBias = Renderer.GetSettings().PCFKernelSize * 0.5f + 0.5f; const TEXTURE_FORMAT ShadowMapFmt = ShadowMapMgr.GetAtlasDesc().Format; - TaskParams.State.DepthBias = (ShadowMapFmt == TEX_FORMAT_D32_FLOAT || ShadowMapFmt == TEX_FORMAT_D32_FLOAT_S8X24_UINT) ? 10000 : 10; + if (ShadowMapFmt == TEX_FORMAT_D32_FLOAT || + ShadowMapFmt == TEX_FORMAT_D32_FLOAT_S8X24_UINT) + { + // Bias = (float)DepthBias * 2**(exponent(max z in primitive) - r) + + // SlopeScaledDepthBias * MaxDepthSlope; + // where r is the number of mantissa bits in the floating point representation (excluding the hidden bit); for example, 23 for float32. + TaskParams.State.DepthBias = 10000; + } + else + { + // Bias = (float)DepthBias * r + SlopeScaledDepthBias * MaxDepthSlope; + // where r is the minimum representable value > 0 in the depth-buffer format converted to float32 + TaskParams.State.DepthBias = 10; + } CreateTask(HnTaskManagerTokens->renderShadowsTask, TaskUID_RenderShadows, TaskParams); // Only render shadows from default material for now