Skip to content

Commit

Permalink
HnTaskManager: added comments about depth bias computation
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Oct 17, 2024
1 parent e9a4ef3 commit 0af9b99
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Hydrogent/src/Tasks/HnTaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HnRenderShadowsTask>(HnTaskManagerTokens->renderShadowsTask, TaskUID_RenderShadows, TaskParams);

// Only render shadows from default material for now
Expand Down

0 comments on commit 0af9b99

Please sign in to comment.