Temporal AA sharpening

If you could offer this in a 4.16 version that would help quite a few people I think… 4.17 is still new and you can’t always update immediately.

Yes the scene will appear more responsive and sharp (compared to original TAA) because the solution in the article i posted is going to reduce the antialiasing effectiveness, as well as the accumulation of the blur on these areas. The only requirement is to have your camera to move in order to gather the required information from the scene which will drive the final blending of the pixels.

Yes, exactly! Since it is bound to camera movement, the static scenes will unable to provide the required informations for the simple equation, and it would require more robust solution (eg, a depth difference approach with an additional temporal pass) to have them work. It’s something i am working on currently, and the end result will likely be possible to be combined with this sharpening pass as well.

Looks good and very advanced so far. Nice work on that. I’m not entirely sure of the reason for some refactors but let’s just have the freedom of the author :slight_smile:

Here, this technology is labeled as TAA afaik, and a very simple approach which can be extended further by anyone. If you wish to reduce the blurriness of the TAA, it might be better to prevent it to happen long beforehand. Post sharpening of the screen best helps with fine adjustments only to pronounce the content for the viewers pleasures.

@hallatore have done an amazing job on demonstrating the possibilites (with the actual implementation too, it is mature) and i’m having a feeling this only is just the beginning you guys have witnessed here :slight_smile: Well done!

Thanks! :slight_smile:
This little project actually started because I got an idea while playing around with the anti-ghosting stuff.
Without AA we have sharp textures, but also sharp edges. With TAA we get (slightly) blurry textures, but also smooth edges.

My idea was that because we have two eyes we see real life details both sharp and blurry. Details on a flat plane (tv screen, paper, wall, etc) we see very sharp since both eyes can focus on the same point in space. But edges of object are never truly sharp because our eyes don’t have a perfect focus point. So in a sense real life edges are smooth and not perfectly sharp.
That’s the concept I’m trying to emulate. TAA already got the smooth part down, it’s just the sharp part that is not 100%.

By using the depth to detect object edges I can avoid sharpening those. Right now I have it set to fade from 0 to 15 world units in depth. As in 15 means 0 sharpening.
The second piece is that I calculate the max contrast between the neighboring pixels. The more contrast already there, the less sharpening is applied. Right now I’ve found a sweet spot of 0 to 4% difference in contrast where 4% means 0 sharpening.
Combining these two gives the resulting image where object edges are unaffected by sharpen, while texture details are affected. And low contrast details gets a slightly more sharpen than already high contrast stuff.

My goal is not to create a new sharpen post process, but to make TAA come as close to the “truth” as possible. The “truth” in this case is TAA with screen percentage set to 200. :slight_smile:
That’s also why I’m doing minor tweaks to the code, it’s hard to find the right balance where smooth stuff is smooth and crisp stuff stay crisp.

The easy part is making it sharper than the default: Imgsli (Default TAA vs. 0.25)
The hard part is matching the “truth”: Imgsli (TAA 200% vs. 0.25)

An unintended side effect is that extreme values hold up much better than r.Tonemapper.Sharpen: Imgsli (Sharpen 1 vs. Dynamic 1.0)
They are both way to high, but I feel sharpen has more artifacts while they deliver about the same amount of texture sharpening.

Just some screen percentage tests. Using this thread to log my work. :slight_smile:

70%: Imgsli
50%: Imgsli
And an interesting one. 100% default vs. 70% dynamic: Imgsli

I could use some feedback on the following code. Does it look correct, is there stuff I can drop?

https://github.com/hallatore/UnrealEngine/blob/TAA_Sharpen/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessTemporalAA.cpp#L1142-L1253

I was giving it a look earlier and it seemed fine and is consistent with the rest of the source. The only thing I’d be concerned about is potentially unknown effects on the overall post stack given the presence (or lack thereof) of other effects. But, I don’t see any issues on my end in-game, so it seems solid.

(Though I’d recommend making your TAA_Sharpen branch the promoted/default branch for your repo – it’s easy enough to do in the repo settings).

It only runs when Temporal AA is also running. https://github.com/hallatore/UnrealEngine/blob/TAA_Sharpen/Engine/Source/Runtime/Renderer/Private/PostProcess/PostProcessing.cpp#L901-L912
@Chris.Bunner Is it required to add a Computer shader pass also?

Moving frames! :slight_smile:
These images are captures while the camera is moving. So it represent what you would see if you took a screenshot while moving.

By default TAA gets blurrier when the camera is moving because of how it reuses frames. It’s actually quite bad. (https://imgsli.com/MDY0NA)
Dynamic improves it a bit (https://imgsli.com/MDY0NQ), but it’s not perfect since TAA blurs it so much.

I’ve looked at the TAA blend that @Konflict made and think it works quite well combined with my code. Adaptive-Blended TAA, a tiny magic for your sharp and responsive scenes - Rendering - Unreal Engine Forums
I reduced the blend amount just a tiny bit to reduce jitter on stuff with very high noise.


BlendFinal = clamp( BlendFinal + sqrt(sqrt(distance(BackN.xy, UV.xy))) * 0.5f , BlendFinal , 1.0f );

The end result is a much better moving frame! :cool: (Imgsli)
It also matches No AA much better than the default AA does. https://imgsli.com/MDY0NA vs. Imgsli

fc5111116bd6834d7813df4b766ae60d7d4156b4.jpeg

Very nice to see the progress you’re making on it, really looks like your change and the one from Konflict work well together.

Will do later, it’s not quite there yet. :slight_smile:
I’ve tweaked the code @Konflict made to combat jitter-artifacts in noisy stuff. It’s more of a movement sharpening than a anti-ghost thing now.

Just a test with a very noisy cube. :slight_smile:

Out of curiosity, is this your sole source of sharpening for the full composition? I realized I had my tonemapper sharpening still at a (relatively low) value, and not sure if I should use small values for the combo or just go straight one way or the other. It’s possible that it’d be more efficient to reserve all sharpening to a single dedicated pass, but I can also see the value in potentially doing mild sharpening at separate stages.

(I’m currently debugging a bunch of engine-side changes I made, so I can’t just launch and test it, was just wondering in the interim).

This looks great. The only reason my VR project is on forward is for MSAA. I would love a sharper temporal AA so I could go back to deferred and ditch the early z pass.

Precisely. This is also the source of the problems with VR where the viewer can get sick of these. Me too, i hate this blurring, and the higher the coefficient for the equation the better the blur gets reduced.

Yes the side effects upon camera movement will result in aliased content showing up since the antialiasing get’s seriously reduced on high values. On a desktop monitor this can be witnessed.

Then it finally serves it’s main purpose. Anti ghosting is only a side effect under given circumstances, but was not among it’s primary function :slight_smile:

No don’t use the tonemapper sharpen on scenes where high contrast can happen. It is best used on low contrast scenes only! You should use only this sharpening that excludes the high contrast areas, thus providing you the sharpening on the fine details only.

If you allow me to recommend this combined solution for your VR project, then please by all means try it! In VR you will find to be less annoying to have a little aliasing artifacts, so you can just go wild with these values and apply strong effect for any or both equations. The resulting deblurred screens expected to cause less sickness, but let us know what are your experiences!

I am currently using TAA in VR because MSAA doesn’t work with SSAO due to SSAO depending on TAA for good quality, so I would definitely try this out. I just can’t update my project to 4.18 at the moment, so I will have to wait until this is available for earlier engine versions, or I will try to port it back myself, but I guess that only makes sense to do after hallatore is done adding new things to this all the time :slight_smile: So it will be a while before I can give feedback on how this feels in VR.

Seeing this hurts my eyes, this is curious to me thought why sharpen when its mostly ment to soften the edges?

Me personally I would never use Unreal Temporal AA, FXAA or even MSAA because its terrible and I prefer to just
draw the image without any aliasing.

This looks interesting when I look at it I mostly would think if it will hit performance hard.

Everyone prefers an image without aliasing, but you can only get an image without aliasing if you use any anti-aliasing technique like TAA, FXAA or MSAA.

What engine version are you on? It’s mostly research for now, but I might give it a go to port it if I got time.

This isn’t meant as a replacement for the tonemapper sharpen. It’s meant as pure TAA anti blur. So it’s correct to use both, since they do slightly different things.

Especially with 4K I get that some prefer no AA over TAA, FXAA etc because of the slight blur they introduce. And it’s exactly what this code is trying to fix. :slight_smile:
The goal is smooth edges but same texture sharpens as with no AA.

I have updated the github repo with the latest changes. It now works well both stationary and while moving. Give it a go! :cool:

Here is the current status/goals of the code.

  1. Textures should have the same sharpness as with no AA. Not less or more.

  2. Edges should have the same smoothness as with default TAA.

  3. While moving textures should have the same sharpness as with no AA. Not less or more.

  4. While moving noisy textures should have the same temporal stability as with default TAA.

  5. and 2. are pretty much done. It looks great with the default value (0.25).

  6. and 4. are working very well, but they are opposites. I can’t reduce the blur further while moving without reducing the temporal stability (jittering) in noisy textures. What I have now feels like a great middle road with unnoticeable difference on noisy textures while greatly increasing the sharpness while moving.

Just another stationary test scene with the current code: Imgsli

7676039d3bbca8da0f32bd89fea6d56b3461e4c3.jpeg

I am on 4.15, but if you would port this to 4.16 then it should be simple for me to port this to 4.15 I think. 4.16 is the version many people are currently still on since 4.17 is very new, so I think having a 4.16 version makes sense.

Awesome!