Glad you like it!
PS: Can’t see any image though.
Here is the latest code btw. Just some minor tweaks.
Personally I found values between 0.2 and 0.4 to be closest to the reference. But it’s all about personal preference, and the code seems to scale pretty well to extreme values.
void MainDynamicSharpenTemporalAAPS(
in noperspective float2 UV: TEXCOORD0,
float4 SvPosition : SV_POSITION,
out float4 OutColor : SV_Target0 )
{
float4 CenterColor = PostprocessInput0.SampleLevel( PostprocessInput0Sampler, UV, 0 );
if (DynamicSharpen <= 0)
{
OutColor = CenterColor;
return;
}
float2 FullResUV = SvPosition.xy * PostprocessInput0Size.zw;
half CenterDepth = CalcSceneDepth(FullResUV);
float4 DepthQuad = GatherSceneDepth(UV, PostprocessInput1Size.zw);
half D1 = abs(CenterDepth - DepthQuad.x);
half D2 = abs(CenterDepth - DepthQuad.y);
half D3 = abs(CenterDepth - DepthQuad.z);
half D4 = abs(CenterDepth - DepthQuad.w);
half NeighborDepth = max(max(D1, D2), max(D3, D4));
half3 C1 = PostprocessInput0.SampleLevel(PostprocessInput0Sampler, UV, 0, int2(-1, 0)).rgb;
half3 C2 = PostprocessInput0.SampleLevel(PostprocessInput0Sampler, UV, 0, int2( 1, 0)).rgb;
half3 C3 = PostprocessInput0.SampleLevel(PostprocessInput0Sampler, UV, 0, int2(-1, -1)).rgb;
half3 C4 = PostprocessInput0.SampleLevel(PostprocessInput0Sampler, UV, 0, int2(-1, 1)).rgb;
half L1 = LuminanceDifference(C1.rgb, CenterColor.rgb);
half L2 = LuminanceDifference(C2.rgb, CenterColor.rgb);
half L3 = LuminanceDifference(C3.rgb, CenterColor.rgb);
half L4 = LuminanceDifference(C4.rgb, CenterColor.rgb);
half NeighborDifference = max(max(L1, L2), max(L3, L4));
// Fade sharpen based on depth difference in world units. (0...15)
half DepthFactor = saturate(1 - NeighborDepth / 15.0);
// Fade sharpen based on luminance difference in percentage. (0...5)
half LuminanceDifferenceFactor = saturate(1 - NeighborDifference * 20.0);
// Ignore the sky since depth info will be wrong.
half DepthLimit = saturate(1 - CenterDepth / 1000000);
half LerpFactor = -DynamicSharpen * DepthFactor * LuminanceDifferenceFactor;
half3 DeltaColor = (C1 + C2 + C3 + C4) - CenterColor.rgb * 4;
CenterColor.rgb += -DeltaColor * DynamicSharpen * DepthFactor * LuminanceDifferenceFactor * DepthLimit;
OutColor = CenterColor;
}