Gen 5 Temporal Anti-Aliasing

Side issue: with no engine changes there seems to be a bug with r.TemporalAASamples. If increased much beyond the default 8 (I noticed it starting at 12) it will periodically run with what looks like no jittering and a lot of aliasing accumulation, and then return to jittering and look fine, over and over. Also this ensure gets tripped:



ensureMsgf(TemporalJitterIndex >= 0 && TemporalJitterIndex < TemporalJitterSequenceLength,
TEXT("TemporalJitterIndex = %i is invalid (TemporalJitterSequenceLength = %i)"), TemporalJitterIndex, TemporalJitterSequenceLength);


And it seems TemporalJitterIndex goes negative. Seems the Halton function will always return 0 when it is given a negative index and that probably causes the oscillation between aliased/unaliased.

edit: Ah, it seems to only happen at low screenpercentages, and so be due to this line boosting the sample count beyond int8 positive range:



// When doing TAA upsample with screen percentage < 100%, we need extra temporal samples to have a
// constant temporal sample density for final output pixels to avoid output pixel aligned converging issues.
TemporalAASamples = float(TemporalAASamples) * FMath::Max(1.f, 1.f / (EffectivePrimaryResolutionFraction * EffectivePrimaryResolutionFraction));


(TemporalJitterSequenceLength gets set from that)

This line should instead clamp to 127, since it gets put into an int8 at some point:



                TemporalAASamples = FMath::Clamp(TemporalAASamples, 1, 255);


I got some decent results. I’m just testing with individual meshes using VRS now because I couldn’t get the whole screen or the texture based one to work yet.

The chair on the left is using 2x2 VRS, and the one on the right normal 1x1. I added an additional mip bias of -1 since when using TAAU it is being sparsely sampled over many frames.

It seems to get significantly less aliasing with the 2 pixel TAA span, but still has some moving noise which I think would be able to be cleared up by making the reconstruction filter aware of VRS.

I think this kind of thing could benefit both this and nvidia’s DLSS with VR. The reconstruction itself could also output to a lower resolution too using VRS or its own logic, so that the texture bandwidth savings aren’t lost from the extra mip bias (for VR the periphery gets extra downsampling anyway due to lens warp).

In each image the chair on the left is using 2x2 variable rate shading.

TAAU (1 pixel jitter span):

Modified TAAU with 2 pixel span:

No AA:

Both Gen4 and Gen5 handled it similarly, with similar improvements with the increased span, I can’t remember which was screenshotted.

When using 4x4 VRS a changed pixel span up to 4 pixels made an even bigger improvement over the default span, but it started getting stronger moving noise and really needs adjustments at that point to not have the 4x4 pixel block edges and corners be seen as underlying features to reconstruct from.

4x4 VRS shows the improvement more. I made sure all these with aa were with gen5 turned on.

Default gen5 90% screenpercentage:

gen5 modified with a 4 pixel span to the jitter pattern, 90% screenpercentage:

no anti aliasing, 100% screenpercentage:

I added a pull request here to fix the sample count overflow issue with temporal aa jitter (more likely for people to run into it with TAAU at low screen percentages, because the configured sample count gets amplified there):

https://github.com/EpicGames/UnrealEngine/pull/7903

1 Like

I’d just like to say your work means a lot. And Communicating with us here is really rare from UE developers, no offense intended. It’s not like other engines, hard to find devs that give time to communicate with us here. Really appreciated.

Aliasing/ghosting is one of the biggest problems I face with dense vegetation in UE, anyone that improves anti aliasing is a legend in my eyes – so thank you.

Upgrading to UE5 seems to be fairly simple, so I’m really looking forward to the temporal improvements coming with UE5.

@Guillaume.Abadie
Are directives

r.TemporalAASamples
r.TemporalAACurrentFrameWeight

Have no effect when Gen5 TAA enabled in 4.*? I’ve tested multiple combinations and astronomical values there is 0 perceived difference so I assume they dont come into play?

2 Likes

Almost giving up on UE cos this issue. All foliage is rendering like garbage, AA seems to get things looking even worst.

Read the thread, proper motion vectors support been stressed out multiple times for tempAA.

@Guillaume.Abadie Thanks for some explanation in the thread. Little wonder if there’s any available paper/report about the optimization of Gen5 TSR, for either ongoing or completed version, compared to previous UE4 TAAU. Pretty interested about that

I was late to discover this, the next gen TAA solution has made me a believer again. I am amazed at how good this is, this is what I needed. I’m now sporting 50% screen resolution and I can barely tell the difference (and I almost always can).

Thank you for your brilliant work <3

@Vioxtar

Are you talking about the same AA as in this thread or is there a newer solution?

Perhaps the op of that thread didn’t tweak it enough?
But if we’re talking about the same AA as was shown in the Matrix demo, hoo boy, that wasn’t pretty… I mean everything else was spectacular, but the temporal smearing just grinds my gears so hard.

Ghosting was addressed by Gulliame earlier:

For jitter/instability at still image, you need to tweak TAA SampleCount and FrameWeight.
Either way when framepace is unstable and FPS spikes between crazy high and crazy low values - ghosting is inevitable due to nature of TAA

Yea, there’s a conflict between SpeedTree9 and Gen5 TAA, in UE5 this resulted in obvious ghosting and smearing, the SpeedTree support team told me to turn on “Output velocities due to vertex deformation” in the project settings, but it was useless, I rely heavily on speedtree, so I hope that solves the problem.
Anyway, I’m very grateful to have EPIC technicians here to answer questions, so thank you!

2 Likes

can i ask what is difference between gen4 and gen5 anti-aliasing and what does that mean??

I see Unreal 5 has something called TSR. How does that play into what’s been said in this thread?

Are there any updated preferences for anti-aliasing when it comes to VR?

Hey did the Temporal Dither AA issue get fixed? I’m trying to use it but it flickers so much it’s causing a strobe effect