Avoid negative thickness values
Signed-off-by: Santi Paprika <santi.gonzalez.cs@gmail.com>
This commit is contained in:
+4
-1
@@ -154,7 +154,10 @@ float DirectionalLightShadow::GetThickness(uint lightIndex, float3 shadowCoords[
|
||||
shadowCoord.y >= 0. && shadowCoord.y * size < size - PixelMargin && shadowCoord.z < (1. - DepthMargin))
|
||||
{
|
||||
const float depthBufferValue = shadowmap.Sample(PassSrg::LinearSampler, float3(shadowCoord.xy, indexOfCascade)).r;
|
||||
const float deltaDepth = abs(shadowCoord.z - depthBufferValue);
|
||||
|
||||
// Normalized thickness (avoid negative values given by to precission or shrinking offsets)
|
||||
const float deltaDepth = max(shadowCoord.z - depthBufferValue,0.0);
|
||||
|
||||
const float viewSpaceThickness = ViewSrg::m_directionalLightShadows[lightIndex].m_far_minus_near * deltaDepth;
|
||||
return viewSpaceThickness;
|
||||
}
|
||||
|
||||
+3
-2
@@ -274,8 +274,9 @@ float ProjectedShadow::GetThickness()
|
||||
float3(atlasPosition.xy * invAtlasSize, atlasPosition.z),
|
||||
/*LOD=*/0
|
||||
).r;
|
||||
|
||||
const float viewSpaceThickness = abs(UnprojectDepth(m_shadowIndex, m_shadowPosition.z) - UnprojectDepth(m_shadowIndex, depthValue));
|
||||
|
||||
// Denormalized thickness (avoid negative values given by to precission or shrinking offsets)
|
||||
const float viewSpaceThickness = max(UnprojectDepth(m_shadowIndex, depthValue) - UnprojectDepth(m_shadowIndex, m_shadowPosition.z), 0.0);
|
||||
return viewSpaceThickness;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user