# Temporal AA sharpening

**URL:** <https://forums.unrealengine.com/t/temporal-aa-sharpening/98676>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [August 17, 2017, 10:06pm UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676 "2017-08-17T22:06:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 17, 2017, 10:06pm UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/1 "2017-08-17T22:06:25Z")

</div>

**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](https://imgsli.com/MDc2MA)  
It produces sharp textures without the edge artifacts that Tonemapper.Sharpen does. [Imgsli](https://imgsli.com/MDc1OA)

**How it works**  
It creates a temporally stable depth mask ([Imgsli](https://imgsli.com/MDc2MQ)) that is used to blend out edges that should not be sharpened.  
It also uses the color contrast to create a secondary mask ([Imgsli](https://imgsli.com/MDc2Mg)) 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/MDc1OA))

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

**Installation**

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

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 17, 2017, 11:17pm UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/2 "2017-08-17T23:17:58Z")

</div>

Here are some screenshots with extreme values.

- Default vs. Sharpen 4: **[Imgsli](https://imgsli.com/MDYyMg)**
- Default vs. Dynamic 4: **[Imgsli](https://imgsli.com/MDYyMQ)**
- Sharpen 4 vs. Dynamic 4: **[Imgsli](https://imgsli.com/MDYyMw)**

---

<div class="post-metadata">

**Author:** ![trentpolack](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/trentpolack/32/1173069_2.png) [@trentpolack](https://forums.unrealengine.com/u/trentpolack)\
**Post date:** [August 18, 2017, 12:04am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/3 "2017-08-18T00:04:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Grayve\_Rose](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Grayve\_Rose](https://forums.unrealengine.com/u/Grayve_Rose)\
**Post date:** [August 18, 2017, 1:49am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/4 "2017-08-18T01:49:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 4:40am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/5 "2017-08-18T04:40:27Z")

</div>

> [@mittense;751392](#):
>
> 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.

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.

> [@Grayve Rose;751435](#):
>
> 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?

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. 🙂

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 5:54am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/6 "2017-08-18T05:54:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John\_Alcatraz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@John\_Alcatraz](https://forums.unrealengine.com/u/John_Alcatraz)\
**Post date:** [August 18, 2017, 10:29am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/7 "2017-08-18T10:29:23Z")

</div>

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](https://forums.unrealengine.com/showthread.php?152521-Adaptive-Blended-TAA-a-tiny-magic-for-your-sharp-and-responsive-scenes)

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 10:38am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/8 "2017-08-18T10:38:25Z")

</div>

> [@John Alcatraz;751560](#):
>
> Could you show some screenshots comparing this to this? [Adaptive-Blended TAA, a tiny magic for your sharp and responsive scenes - Rendering - Epic Developer Community Forums](https://forums.unrealengine.com/showthread.php?152521-Adaptive-Blended-TAA-a-tiny-magic-for-your-sharp-and-responsive-scenes)

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.

---

<div class="post-metadata">

**Author:** ![trentpolack](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/trentpolack/32/1173069_2.png) [@trentpolack](https://forums.unrealengine.com/u/trentpolack)\
**Post date:** [August 18, 2017, 10:42am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/9 "2017-08-18T10:42:14Z")

</div>

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

```auto

// TAACHANGE_Begin.
<RAWR>
// TAACHANGE_End.

```

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

---

<div class="post-metadata">

**Author:** ![John\_Alcatraz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@John\_Alcatraz](https://forums.unrealengine.com/u/John_Alcatraz)\
**Post date:** [August 18, 2017, 10:45am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/10 "2017-08-18T10:45:50Z")

</div>

> [@hallatore;751563](#):
>
> 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.

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.

> [@mittense;751565](#):
>
> It makes it a lot easier for people to integrate changes.

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.

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 10:50am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/11 "2017-08-18T10:50:40Z")

</div>

> [@John Alcatraz;751568](#):
>
> 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.

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! 😉

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. 🙂

---

<div class="post-metadata">

**Author:** ![trentpolack](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/trentpolack/32/1173069_2.png) [@trentpolack](https://forums.unrealengine.com/u/trentpolack)\
**Post date:** [August 18, 2017, 10:51am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/12 "2017-08-18T10:51:58Z")

</div>

> [@John Alcatraz;751568](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 10:57am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/13 "2017-08-18T10:57:07Z")

</div>

> [@mittense;751572](#):
>
> 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?

---

<div class="post-metadata">

**Author:** ![trentpolack](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/trentpolack/32/1173069_2.png) [@trentpolack](https://forums.unrealengine.com/u/trentpolack)\
**Post date:** [August 18, 2017, 11:09am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/14 "2017-08-18T11:09:29Z")

</div>

> [@hallatore;751577](#):
>
> 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:

```auto

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

```

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 11:12am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/15 "2017-08-18T11:12:35Z")

</div>

> [@mittense;751580](#):
>
> 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:

OK thanks. 🙂

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.

---

<div class="post-metadata">

**Author:** ![trentpolack](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/trentpolack/32/1173069_2.png) [@trentpolack](https://forums.unrealengine.com/u/trentpolack)\
**Post date:** [August 18, 2017, 11:16am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/16 "2017-08-18T11:16:02Z")

</div>

> [@hallatore;751582](#):
>
> OK thanks. 🙂
> 
> 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.

---

<div class="post-metadata">

**Author:** ![Chosker](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chosker/32/710746_2.png) [@Chosker](https://forums.unrealengine.com/u/Chosker)\
**Post date:** [August 18, 2017, 11:42am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/17 "2017-08-18T11:42:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 11:46am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/18 "2017-08-18T11:46:57Z")

</div>

> [@Chosker;751597](#):
>
> 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

---

<div class="post-metadata">

**Author:** ![John\_Alcatraz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@John\_Alcatraz](https://forums.unrealengine.com/u/John_Alcatraz)\
**Post date:** [August 18, 2017, 11:58am UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/19 "2017-08-18T11:58:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hallatore](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hallatore/32/1109226_2.png) [@hallatore](https://forums.unrealengine.com/u/hallatore)\
**Post date:** [August 18, 2017, 12:05pm UTC](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676/21 "2017-08-18T12:05:36Z")

</div>

> [@John Alcatraz;751605](#):
>
> 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.

[Next page](https://forums.unrealengine.com/t/temporal-aa-sharpening/98676.md?page=2)
