Download

Temporal AA sharpening

Updated 03.09.2017
Rewrote most of the code and put it into separate files. [HR][/HR]

I’ve added a step to the TAA post process that sharpens the image without destroying the initial TAA result.
It produces sharp textures while preserving smooth edges on foliage, characters etc…

r.TemporalAASharpen between 0.1 and 0.3 gives good natural results. Imgsli
It produces sharp textures without the edge artifacts that Tonemapper.Sharpen does. Imgsli

How it works
It creates a temporally stable depth mask (Imgsli) that is used to blend out edges that should not be sharpened.
It also uses the color contrast to create a secondary mask (Imgsli) that is used to blend out high contrast pixels. This mask is very subtle, and helps to avoid sharpening already high contrast pixels that usually results in white or black borders. (Zoom in: Imgsli)

https://imgsli.com/i/cce12110-b120-4b70-851e-80423868c4cb.jpg

Installation
4.17 version: https://github.com/hallatore/UnrealE…A_Sharpen_4.17
4.16 version: https://github.com/hallatore/UnrealE…A_Sharpen_4.16
4.15 version: https://github.com/hallatore/UnrealE…A_Sharpen_4.15

  1. Add the changes from the latest commit.
  2. Run GenerateProjectFiles to update the solution with the new files.
  3. Build the solution.
2 Likes

Here are some screenshots with extreme values.

  • Default vs. Sharpen 4: Imgsli
  • Default vs. Dynamic 4: Imgsli
  • Sharpen 4 vs. Dynamic 4: Imgsli

I’m hoping to give this a go tomorrow or this weekend some time (I just upgraded my fork to 4.17.1 so I am tired of engine builds for the day), but nice work, this looks rad. Does it hold up in-motion, since that’s largely where TAA is at its worst.

Have been coming across these same things on my own project, trying to compromise between AA types and how it affects art, ghosting, etc. I think I’ve come to a compromise but, I would like to try out your settings, unfortunately the page returns with a 404 page not found error. Also was curious, did you make all of this through blueprint with console commands or was it some kind of material programming and/or coding?

It’s run right after TAA every frame, so it should do a good job every frame. It won’t remove stuff like ghosting though, that can be dealt with by other settings/tweaks.

You need to be signed into github and have access to the UnreanEngine repo. This is a tweak to the core engine, not a blueprint or material. :slight_smile:

Updated the code with the console variable r.TemporalAADynamicSharpen. 0.2 - 0.25 is about the same as with no AA, but works quite a bit higher.
It’s more forgiving than normal sharpen with extreme values.

Could you show some screenshots comparing this to this? Adaptive-Blended TAA, a tiny magic for your sharp and responsive scenes - Rendering - Unreal Engine Forums

That one is for ghosting when you move the camera around. This is for the the blurry textures you get from TAA.
They solve different problems, but I think they could work well together.

One thing I’d recommend is to cap your changes with



// TAACHANGE_Begin.
<RAWR>
// TAACHANGE_End.

It makes it a lot easier for people to integrate changes.

I think the other one is also for making the scene appear more sharp.

How well does your sharpening work with SSAO? The tonemapper sharpen makes the SSAO very noisy again.

Why would those comments be needed? You see the commits he made, so you can just merge those commits and its clear what changed in those. I think comments in the code indicating where something was changed would just make it ugly.

The other changes make the scene more sharp when you move around. I don’t think it should change the sharpness when the camera is stationary?
This method should have no effect on SSAO. Try it out! :wink:

I want eventually want to submit this as a pull request. Comments would be nice if it was just for custom integration.
Will still have to clean up some of the code, it’s not done yet. :slight_smile:

Because, as time goes on, it becomes a lot more difficult for that to be viable, especially when working within epic forks.

It’s also a general convention for any third-party engine alterations.

Any good docs on conventions? Just done minor pull requests that didn’t need any commenting.
Got any examples in the current source?

You wouldn’t want to do this in a pull request to Epic proper, but until then, this is an example of how NVIDIA handles it:


// NVCHANGE_BEGIN: Nvidia Volumetric Lighting
#if WITH_NVVOLUMETRICLIGHTING
	NVVolumetricLightingBeginAccumulation( RHICmdList );
#endif
// NVCHANGE_END: Nvidia Volumetric Lighting

OK thanks. :slight_smile:

Would love to get some feedback on the code also. Haven’t written any C++ or shader code before, so most of the .cpp stuff is just guessing.

I’m hoping to give it a go later today; I’ll report back with any feedback/screens.

thanks for sharing this

I gave it a go but I had some compiler errors. after fixing them the engine crashes on startup complaining that it failed to compile the shader
I guess I really need 4.17 for this? I’m on 4.16 at the moment but I could try once I update to 4.17

It’s against the current master branch (4.18), so there might be some changes it doesn’t like. Easiest to just download the whole thing.

I don’t know enough to answer if there are parts there that are new after 4.16. What is the shader error? You can turn on shader compilation errors in consolevariables.ini

I would like to see how it looks like in my game, but I’m on 4.15, so I guess if it doesn’t even work on 4.16, it definitely won’t work on 4.15.

I think it should work. Just turn on r.ShaderDevelopmentMode=1 in Engine/Config/ConsoleVariables.ini so you see what it’s complaining about.

The code is pretty basic, so I don’t see what would have changed between 4.15 and now.