简体   繁体   中英

DirectX 12 do not update the pixel color after some frames

When I try to implement TAA, I update the pixel color like this:

float4 PS(VertexOut pin) : SV_Target
{ 
    float2 currPos = pin.PosH.xy * gInvRenderTargetSize;
    float2 histPos = currPos + gVelocityBuffer.Sample(gsamPointClamp, currPos).xy;

    float4 currPixel = gCurrFrameMap.Sample(gsamPointClamp, currPos);
    float4 histPixel = gHistoryFrameMap.Sample(gsamPointClamp, histPos);
    
    if(gFirstFrame == 1)
    {
        return currPixel;
    }
    
    float4 taaPixel = 0.05 * currPixel + 0.95 * histPixel;
    return taaPixel;
}

But after some frames it just show the history pixel instead of the new pixel, making the render result dirty. How could I solve this?

This is the render target picture

在此处输入图像描述

The history frame

在此处输入图像描述

The current frame

在此处输入图像描述

The render target frame, and we can see that the pixel color do not change here

在此处输入图像描述

Using the 95% History/5% Current split, you should completely eliminate any ghosting artifacts after 20 frames.

Instead, you eventually end up returning just histPixel with no contribution from currPixel , which indicates that some amount of histPixel is ending up in currPixel .

I can't say for certain without a video, but I think you are using the previous displayed frame for gCurrFrameMap . This still allows a better quality image, but only 20 frames (with each frame contributing less and less) of improvement.

Also, Sample the four neighboring pixels and clamp histPixel with the min and max of currPixel and those four samples. It will eliminate ghosting artifacts without having to reset to currPixel at gFirstFrame .

After a few days I finally found the solution T_T. This problem is caused by the low precision of DXGI_FORMAT_R8G8B8A8_UNORM , so the updated value and the previous value will have the same RGBA value. Now I changed it to DXGI_FORMAT_R16G16B16A16_FLOAT and it was solved properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM