Hello!
We discovered a graphic glitch when combining DFAO with dynamic resolution. We notice the issue as a displaced character ghost, just as if the AO was being applied at the wrong screen coordinates (please see the video and sample project attached).
We think we isolated the cause of the issue in the code of UpdateHistoryDepthRejectionPS shader (Engine\Shaders\Private\DistanceFieldLightingPost.usf). It seems that the velocity buffer is not being sampled with the right coordinates or so when the dynamic resolution is involved. The shader approximates the ScreenVelocity first using this code
float4 ThisClip = float4(UVAndScreenPos.zw, ConvertToDeviceZ(SceneDepth), 1);
float4 PrevClip = mul(ThisClip, View.ClipToPrevClip);
float2 PrevScreen = PrevClip.xy / PrevClip.w;
float2 ScreenVelocity = UVAndScreenPos.zw - PrevScreen;
and then, the calculated velocity is overridden if the sample value of the velocity texture is non-zero:
// The scene velocity texture is rendered as a texture atlas for all views,
// so first convert the vertex shader’s UV coordinates to the size of the view rect and offset into the atlas
// before converting back to the correct UV coordinates.
float2 FullResTexel = (UVAndScreenPos.xy * View.ViewSizeAndInvSize.xy + View.ViewRectMin.xy - .5f) * View.BufferSizeAndInvSize.zw;
float4 EncodedVelocity = Texture2DSampleLevel(VelocityTexture, VelocityTextureSampler, FullResTexel, 0);
if (EncodedVelocity.x > 0.0)
{
ScreenVelocity = DecodeVelocityFromTexture(EncodedVelocity).xy;
}
As said in the shader code comment, the velocity texture is some sort of atlas, and it could be that the coordinates to sample it are miscalculated in the case of using multiple viewports (editor) or when dynamic resolution is enable (for instance in consoles). If we comment the code that samples the screen velocity from the velocity texture, the glitch dissapears.
We have been seeing this glitch since UE 5.6 at least. We are on 5.7.3 and the issue is present too. We are able to reproduce it on all consoles.
Is there a known way to fix it within UE 5.7.3 or is there a workaround?
Thanks in advance.
Regards,
Marcos Falcón Pérez
Tech Director
Saber Interactive
[Attachment Removed]