Files
UnrealEngineUWP/Engine/Shaders/Private/TemporalSuperResolution/TSRMergeRejection.usf
guillaume abadie 88d9266523 Fixes TSR velocity hole-filling on depth velocities
This is of particular importance to not end up velocity hole filling on walking skeletal meshes as well as moving cars

#rb none
#jira UE-192040, FORT-616233

[CL 27183611 by guillaume abadie in ue5-main branch]
2023-08-17 16:01:23 -04:00

71 lines
1.7 KiB
Plaintext

// Copyright Epic Games, Inc. All Rights Reserved.
#include "TSRCommon.ush"
//------------------------------------------------------- CONFIG
#define TILE_SIZE 8
//------------------------------------------------------- PARAMETERS
float4x4 ClipToResurrectionClip;
Texture2D<float2> ClosestDepthTexture;
Texture2D<tsr_half4> HistoryRejectionTexture;
RWTexture2D<float2> DilatedVelocityOutput;
//------------------------------------------------------- ENTRY POINT
[numthreads(TILE_SIZE * TILE_SIZE, 1, 1)]
void MainCS(
uint2 GroupId : SV_GroupID,
uint GroupThreadIndex : SV_GroupIndex)
{
uint GroupWaveIndex = GetGroupWaveIndex(GroupThreadIndex, /* GroupSize = */ TILE_SIZE * TILE_SIZE);
float4 Debug = 0.0;
tsr_short2 InputPixelPos = (
tsr_short2(InputPixelPosMin) +
tsr_short2(GroupId) * tsr_short2(TILE_SIZE, TILE_SIZE) +
Map8x8Tile2x2Lane(GroupThreadIndex));
tsr_half ResurrectionMask = HistoryRejectionTexture[InputPixelPos].a;
bool bIsResurrectionBetter = ResurrectionMask > tsr_half(1.5 / 255.0);
BRANCH
if (bIsResurrectionBetter)
{
float2 ResurrectedEncodedScreenVelocity;
{
float DeviceZ = ClosestDepthTexture[InputPixelPos].g;
float2 ScreenPos = ApplyScreenTransform(float2(InputPixelPos), InputPixelPosToScreenPos);
float4 ThisClip = float4(ScreenPos, DeviceZ, 1);
float4 ResurrectionClip = mul(ThisClip, ClipToResurrectionClip);
float2 ResurrectionScreen = ResurrectionClip.xy / ResurrectionClip.w;
ResurrectedEncodedScreenVelocity = EncodeVelocityToTexture(float3(ScreenPos - ResurrectionScreen, 0.0)).xy;
}
DilatedVelocityOutput[InputPixelPos] = ResurrectedEncodedScreenVelocity;
}
else
{
// NOP
}
#if DEBUG_OUTPUT
{
DebugOutput[tsr_short3(InputPixelPos, 0)] = Debug;
}
#endif
}