Switch directional light to use the same reformulation as projected shadow and reduce to 16 bit float RT for perf
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
"Attachment": "Depth"
|
||||
},
|
||||
"ImageDescriptor": {
|
||||
"Format": "R32_FLOAT"
|
||||
"Format": "R16_FLOAT"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
"Attachment": "Input"
|
||||
},
|
||||
"ImageDescriptor": {
|
||||
"Format": "R32_FLOAT"
|
||||
"Format": "R16_FLOAT"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
+6
-4
@@ -356,8 +356,9 @@ float DirectionalLightShadow::GetVisibilityFromLightEsm()
|
||||
{
|
||||
const float distanceWithinCameraView = depthDiff / (1. - distanceMin);
|
||||
const float3 coord = float3(shadowCoord.xy, indexOfCascade);
|
||||
const float expDepthInShadowmap = expShadowmap.Sample(PassSrg::LinearSampler, coord).r;
|
||||
const float ratio = exp(-EsmExponentialShift * distanceWithinCameraView) * expDepthInShadowmap;
|
||||
const float occluder = expShadowmap.Sample(PassSrg::LinearSampler, coord).r;
|
||||
const float exponent = -EsmExponentialShift * (distanceWithinCameraView - occluder);
|
||||
const float ratio = exp(exponent);
|
||||
|
||||
m_debugInfo.m_cascadeIndex = indexOfCascade;
|
||||
return saturate(ratio);
|
||||
@@ -385,8 +386,9 @@ float DirectionalLightShadow::GetVisibilityFromLightEsmPcf()
|
||||
{
|
||||
const float distanceWithinCameraView = depthDiff / (1. - distanceMin);
|
||||
const float3 coord = float3(shadowCoord.xy, indexOfCascade);
|
||||
const float expDepthInShadowmap = expShadowmap.Sample(PassSrg::LinearSampler, coord).r;
|
||||
float ratio = exp(-EsmExponentialShift * distanceWithinCameraView) * expDepthInShadowmap;
|
||||
const float occluder = expShadowmap.Sample(PassSrg::LinearSampler, coord).r;
|
||||
const float exponent = -EsmExponentialShift * (distanceWithinCameraView - occluder);
|
||||
float ratio = exp(exponent);
|
||||
|
||||
static const float pcfFallbackThreshold = 1.04;
|
||||
if (ratio > pcfFallbackThreshold)
|
||||
|
||||
@@ -63,12 +63,7 @@ void MainCS(uint3 dispatchId: SV_DispatchThreadID)
|
||||
// So this converts it to "depth" to emphasize the difference
|
||||
// within the frustum.
|
||||
const float depth = (depthInClip - distanceMin) / (1. - distanceMin);
|
||||
|
||||
// Todo: Expose Esm exponent slider for directional lights
|
||||
// This would remove the exp calculation below, collapsing it into a subtraction in DirectionalLightShadow.azsli
|
||||
// ATOM-15775
|
||||
const float outValue = exp(EsmExponentialShift * depth);
|
||||
PassSrg::m_outputShadowmap[dispatchId].r = outValue;
|
||||
PassSrg::m_outputShadowmap[dispatchId].r = depth;
|
||||
break;
|
||||
}
|
||||
case ShadowmapLightType::Spot:
|
||||
|
||||
Reference in New Issue
Block a user