This is absolutely the best single thing I’ve learned regarding visual quality in UE4. Thanks!!!
So, I’m finding those settings pretty brutal on my eyes (at least in a dynamic, deferred scene). Here’s what I do:
; Sharpen on the tonemapper side. r.Tonemapper.Sharpen=1
And since I don’t really care about performance right now:
; Max AA quality. r.PostProcessAAQuality=6 r.TemporalAASamples=32 r.TemporalAASharpness=1
Post-Stack Sharpening Effect
That gets me most of the way, but I also have a fairly simple sharpening post material that I apply in my post-stack as well. I just tossed them up in our public repo: joymachine-public/ue4 at main · trentpolack/joymachine-public · GitHub
I have the base material as well as my settings on a material instance of it in there.
r.TemporalAASamples=32 does not affect performance but it just tell how many jitter locations temporalAA will use. Bigger the number more time it will take to full cycle to loop. This might cause judder and excessive blurriness. I have noticed that r.TemporalAASamples=4 or 8 is optimal depending on target frame rate.
I don’t know, after jumping back and forth between all the values from 1/2/4/8/16/32, I’m still of the mind that 32 looks the best. Here’s my scene:
I went with these settings. I think it might vary a bit from setup to setup.
r.TemporalAACurrentFrameWeight = .1 r.TemporalAASamples = 4 r.Tonemapper.Sharpen = .2
Before/After images: Imgsli
Found combining the information here with the ghosting change here
TXAA is much better. Just thought I would post it for anyone that runs into this thread. With the 2 changes it is much more usable.
I played around with the settings some more and ended up with a pretty decent result. The sharpness is well preserved while avoiding both ghosting and aliasing when moving around.
r.TemporalAACurrentFrameWeight 0.2 r.TemporalAASamples 4 r.Tonemapper.Sharpen 0.8 // Somewhere between 0.5 and 1.0 seems like a sweet spot.
No AA vs. TAA (Notice how well the sharpness is preserved)
Video showing No AA vs. TAA
Default TAA vs. Tweaked TAA
The biggest factor to ghosting seems to be Motion blur. Turning that off helps, but you can also do the following.
Here is a trick I used to reduce ghosting even more by changing the last frame weight when the camera is moving.
Those changes was added by default in 4.15, so no need to play around with the source just for that.
looks quite good, these are the exact settings I used for my UE4 summer jam entry (shootergame-based). in my eyes it makes the edges look slightly jagged but it’s also the best tradeoff I could get
however it’s a case by case basis. in the project we have at work (top-down city builder) the ghosting it very extreme from fast camera movements. I think even for third person games it’s also not enough
even with these settings I think the biggest issue right now is how the Current Frame Weight works: it stacks on top of the previous frame which already stacked with the previous one and so on, so all each previous frame is still there, in lower opacity each time, up to infinity.
if it could somehow work that it keeps the last X frames as buffers and average them alone (so older frames are already discarded) the temporality would be greatly reduced and so the ghosting would be minimized. however I don’t think keeping X full-resolution buffer frames is really affordable :rolleyes:
I made a this to change the frame weight when the camera is moving. I think the result looks really good.
Nice temporal stability when standing still, no ghosting when moving around.
Still need to tweak the movement threshold and the weight amounts though.
curious to see what you’ve made but the attachment isn’t working
Here is a demo of the settings above. It’s not so easy to see on youtube, but I didn’t see any ghosting at all on my screen.
Tweaked the code some more. Sharpen set to 0.8 is pretty much the same sharpness as with no AA at all.
I also updated the blueprint attached to the camera. It sets LastFrameWeight to 0.5 and reduces Sharpen to 0.5 (the higher LastFrameWeight, the less Sharpen we need)
Here are 3 examples where I move the mouse back and forth with motion blur amount set to 0.1. Quite pleased with the result
It is all cute, but
Re-introduces projection matrix jitter into the image, and at values above 0.1 it is highly noticable.
Something witty has to be done with history clamping. Has anyone actually tried something in that field? Maybe some sort of clamping algo, that is adaptive to velocity ?
I have almost no jitter with the settings above. But if I set r.TemporalAASamples higher than 4 they start to show.
Setting r.TemporalAACurrentFrameWeight to 0.2 was originally to avoid ghosting. But with the camera tweak you could possibly get away with setting it to something like 0.1.
Also it seems motion blur and TAA goes hand in hand. You should probably use different based on motion blur on/off.
Preferably I would set the TemporalAACurrentFrameWeight per pixel based on it’s motion vector. But I have no idea how to start playing around with that.
With the camera logic I posted above I have tweaked the settings a bit.
The biggest difference is that the texture sharpness now is exactly the same as with no AA applied. (Compare NO AA vs. these settings: Imgsli)
Here you can compare the default AA’s sharpness vs. these settings: Imgsli
And here you can see the temporal stability is maintained.
r.TemporalAACurrentFrameWeight 0.1 r.TemporalAASamples 4 r.Tonemapper.Sharpen 0.5
New camera adjustment logic
I tweaked the blueprint to adjust the settings based on camera movement. Combined with these settings it seems to work very well.
You can copy & paste this into your blueprint to get the code: blueprint · GitHub
PS: I’ve set the max FrameWeight to 0.35. This seems to be a good balance between temporal stability and ghosting.
But only if you entertain specular aliasing, and some cheeky noise once you turn your camera around
Well, I’m not a big fan of using Tonemapper sharpen to solve ghosting issues. It introduces artifacting of its own.
Tweaking current frame weight based on world speed of the camera might seem situationally useful for certain games. You can also scale final blend by velocity data in the shader.
Problem with using reduced samples for TAA, is that at 4 samples, you are just using typical MSAA jitter offset pattern. It reduces TAA effectiveness to some degree as opposed to Halton sequence at 5 samples and above.
Improving TAA ,in my view, should be probably separated into two parts. The first part is coming up with better way of history clamping(I believe that I’ve read somewhere that orienting and stretching neightbour sampling pattern in direction of velocity helps, but haven’t tried it.).
The second part would be a better solution to calculating velocity offset based on depth difference. Right now the cross pattern with offset of 2 is used used by default. I’ve actually had some limited success with using a larger SNN filter for that, which blurs the borders of objects more, but results in less overall smearing of multiple layers of moving objects. This one in particular relates to foliage.
The sharpen is to “re-sharpen” the image since blur is a side effect of TAA.
It seems there are two scenarios. With and without motion blur. And I can only seem to produce ghosting with motion blur enabled.
The good thing is that it seems without motion blur higher sample count and lower FrameWeight works nicely.
So I see it as two separate problems.
- TAA introduces blur. Using sharpen at 0.5 seems to nullify that. (if you sharpen without TAA you would of course over-sharpen the image)
- Camera Motion blur introduces ghosting.