New Contrast Adaptive Sharpening from AMD

  • lowenz
  • Topic Author
More
5 years 5 months ago #1 by lowenz New Contrast Adaptive Sharpening from AMD was created by lowenz
The following user(s) said Thank You: BeTa, JBeckman, Viper_Joe, aaronth07

Please Log in or Create an account to join the conversation.

  • JBeckman
More
5 years 5 months ago - 5 years 5 months ago #2 by JBeckman Replied by JBeckman on topic New Contrast Adaptive Sharpening from AMD
Hmm interesting to see AMD already putting this up on their Github, though doesn't some of the sharpen effects for ReShade 3.0+ already have contrast adaptive support of some kind though it will be interesting to read more on how the effect here works even if that is the case. :)

Not that I know very much about shaders, mostly using the adaptive sharpness effect(s) (One with depth buffer and the other without for games with limited or no depth buffer hook for ReShade.) and I haven't looked it up too much for how it really works in the shader code itself plus what other sharpness shaders there are since I think there's two or three at least. :)

Neat!

EDIT: Hmm wonder if it could work similar to SMAA with the .fxh being the source well I wouldn't really know, lots of interesting little options in there though.
Last edit: 5 years 5 months ago by JBeckman.
The following user(s) said Thank You: BeTa

Please Log in or Create an account to join the conversation.

  • BeTa
More
5 years 4 months ago - 5 years 4 months ago #3 by BeTa Replied by BeTa on topic New Contrast Adaptive Sharpening from AMD
:P the question is, can we salvage it or parts from it for benefiting ReShade or its shaders?

edit:

on second thought..

Damn that thing is complex... --> github.com/GPUOpen-Effects/FidelityFX/bl...as-headers/ffx_cas.h

i guess not in the foreseeable future... :silly:
Last edit: 5 years 4 months ago by BeTa.

Please Log in or Create an account to join the conversation.

  • Iddqd
More
5 years 4 months ago #4 by Iddqd Replied by Iddqd on topic New Contrast Adaptive Sharpening from AMD
Probably one by one port with CAS_BETTER_DIAGONALS, CAS_GO_SLOWER and noScaling
link: gist.github.com/SLSNe/bbaf2d77db0b2a2a0755df581b3cf00c

Please Log in or Create an account to join the conversation.

  • Martigen
More
5 years 4 months ago #5 by Martigen Replied by Martigen on topic New Contrast Adaptive Sharpening from AMD

BeTa wrote: :P the question is, can we salvage it or parts from it for benefiting ReShade or its shaders?

edit:

on second thought..

Damn that thing is complex... --> github.com/GPUOpen-Effects/FidelityFX/bl...as-headers/ffx_cas.h

i guess not in the foreseeable future... :silly:

I've seen more complex shaders. But if anyone can port this, Marty can :) @MartyMcFly

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
5 years 4 months ago - 5 years 4 months ago #6 by Marty McFly Replied by Marty McFly on topic New Contrast Adaptive Sharpening from AMD
Damn, this comes at an awkward moment, I was just about to release a qUINT sharpen shader, now everyone would think I stole this when I release it for everyone :P

I don't know if the license allows for porting this to ReShade, technically HBAO+ is also open source but we can't port it to ReShade due to its license - I ported HBAO+, but can't release it.
This shader here is mostly that huge because they unrolled everything (instead of do x 10 times it's do x do x do x....), optimized it for GCN architecture and also it is in compute shader format so there's things that can't be done pixel shaders like that. Doesn't mean though it's impossible to port to ReShade though, I'd rather look at the documentation which is above and recreate it.

EDIT: checked it. seems that this port iddqd posted is pretty close already, scaling is not required as this feature would be an upscale sharpener, so raise resolution and at the same time sharpen.. CAS go slower is also fine, and better diagonals as well, since the shader itself is so fast already, it doesn't matter.

EDIT2: vectorized math, that makes it much easier to read, no reason to do all operations separately except on GCN. Left most of it as is, except the last part, restructured it so it compiles to less instructions and more independent calculations so that might be less cycles, idk.

pastebin.com/iUmDXTVP
Last edit: 5 years 4 months ago by Marty McFly.
The following user(s) said Thank You: Wicked Sick, BeTa, jas01, Qsimil, Ryukou36, Viper_Joe, Raughie

Please Log in or Create an account to join the conversation.

  • Qsimil
More
5 years 4 months ago - 5 years 4 months ago #7 by Qsimil Replied by Qsimil on topic New Contrast Adaptive Sharpening from AMD

Marty McFly wrote: Damn, this comes at an awkward moment, I was just about to release a qUINT sharpen shader, now everyone would think I stole this when I release it for everyone :P

I don't know if the license allows for porting this to ReShade, technically HBAO+ is also open source but we can't port it to ReShade due to its license - I ported HBAO+, but can't release it.
This shader here is mostly that huge because they unrolled everything (instead of do x 10 times it's do x do x do x....), optimized it for GCN architecture and also it is in compute shader format so there's things that can't be done pixel shaders like that. Doesn't mean though it's impossible to port to ReShade though, I'd rather look at the documentation which is above and recreate it.

EDIT: checked it. seems that this port iddqd posted is pretty close already, scaling is not required as this feature would be an upscale sharpener, so raise resolution and at the same time sharpen. CAS go slower is also fine, and better diagonals as well, since the shader itself is so fast already, it doesn't matter.

EDIT2: vectorized math, that makes it much easier to read, no reason to do all operations separately except on GCN. Left most of it as is, except the last part, restructured it so it compiles to fewer instructions and more independent calculations so that might be fewer cycles, idk.

pastebin.com/iUmDXTVP


Does HBAO+ shader exist for Patreon supporters? :cheer:

Anyway that CAS shader looks great, thanks :) works fine in Division 2 DX12.
Last edit: 5 years 4 months ago by Qsimil.

Please Log in or Create an account to join the conversation.

  • BeTa
More
5 years 4 months ago - 5 years 4 months ago #8 by BeTa Replied by BeTa on topic New Contrast Adaptive Sharpening from AMD
:ohmy: :woohoo: :kiss: McFly !!!!!!! U Sir, are a Genius...

This works also in Wreckfest.. and its pretty also.. Is it better then FilmicAnamorphSharpen or FilmicSharpen?
Im not really shure... But i think CAS looks a bit more agressive, but could be cause you cant fine tune it like teh Filmic ones..

Theres only one thing that bothers me.. Even at "0" theres still sharpening applied.

Guess needs to be modified a bit.. But hey, this is great stuff and i just wrote this yesterday.. Damn u are a fast one..

:silly:
Last edit: 5 years 4 months ago by BeTa.

Please Log in or Create an account to join the conversation.

  • Niko of Death
More
5 years 4 months ago #9 by Niko of Death Replied by Niko of Death on topic New Contrast Adaptive Sharpening from AMD

Marty McFly wrote: Damn, this comes at an awkward moment, I was just about to release a qUINT sharpen shader, now everyone would think I stole this when I release it for everyone :P

I don't know if the license allows for porting this to ReShade, technically HBAO+ is also open source but we can't port it to ReShade due to its license - I ported HBAO+, but can't release it.
This shader here is mostly that huge because they unrolled everything (instead of do x 10 times it's do x do x do x....), optimized it for GCN architecture and also it is in compute shader format so there's things that can't be done pixel shaders like that. Doesn't mean though it's impossible to port to ReShade though, I'd rather look at the documentation which is above and recreate it.

EDIT: checked it. seems that this port iddqd posted is pretty close already, scaling is not required as this feature would be an upscale sharpener, so raise resolution and at the same time sharpen.. CAS go slower is also fine, and better diagonals as well, since the shader itself is so fast already, it doesn't matter.

EDIT2: vectorized math, that makes it much easier to read, no reason to do all operations separately except on GCN. Left most of it as is, except the last part, restructured it so it compiles to less instructions and more independent calculations so that might be less cycles, idk.

pastebin.com/iUmDXTVP

I assume this would be optimized more for RDNA rather than GCN, seeing as the universal implementation (Radeon Image Sharpening) is only available on Navi cards. Although perhaps the architectures are similar enough that the same optimizations apply to both.

Please Log in or Create an account to join the conversation.

  • BeTa
More
5 years 4 months ago #10 by BeTa Replied by BeTa on topic New Contrast Adaptive Sharpening from AMD
:ohmy: someone else also made an shader at Reddit.

--> www.reddit.com/r/Amd/comments/cc0575/i_p...shade_so_anyone_can/

I ported FidelityFX CAS to ReShade so anyone can use it, with nearly any game
Discussion

Download ffx_a.h and ffx_cas.h from the GPUOpen repository (click "Raw" then you can Ctrl-S the file)
github.com/GPUOpen-Effects/FidelityFX/tr..._CAS/ffx-cas-headers

Download my wrapper shader and save it as FidelityFX_CAS.fx (same again, "Raw" then save)
pastebin.com/yyTqn7Xh

Put all three files in your ReShade shader folder

Tweak the sharpness parameter to your liking. AMD recommends leaving it at 0.0 for minimal artifacts but it can be increased up to 1.0 for more aggressive sharpening.

It will be a little slower than the driver version since ReShade doesn't support FP16/RPM, and I'm pretty sure this version won't work in DX9 games, but I've tested both DX11 and OpenGL games successfully. Looks pretty good to me.

Keep in mind that sharpening should ideally be done before film grain is added, otherwise the grain gets amplified, so for best results you may need to disable in-game film grain and instead apply a ReShade grain effect after CAS.


i guess he did it different? He included the Original FidelityFX files?
Whats the diff. between his and yours?

Please Log in or Create an account to join the conversation.

  • jsheard
More
5 years 4 months ago #11 by jsheard Replied by jsheard on topic New Contrast Adaptive Sharpening from AMD
That's mine, I just did the bare minimum to get AMDs code working inside ReShade. It can probably be done better.
The following user(s) said Thank You: BeTa, ChrisG683

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
5 years 4 months ago - 5 years 4 months ago #12 by Marty McFly Replied by Marty McFly on topic New Contrast Adaptive Sharpening from AMD
That's actually the better way to do it, just like SMAA you're usually supposed to keep the header intact and just load it and give it the data it needs so this is probably the most faithful version. I'll check the assembly out of curiosity later.

EDIT: So I compiled both versions and the wrapped one is faster and shorter, due to missing CAS_GO_SLOWER and CAS_BETTER_DIAGONALS which the other inline version has. When I enable these, I can see no visual difference but the wrapped one is 64 instructions where the one I optimized is 48. How that comes to pass, I'm uncertain, either way jsheard can't be blamed, he did everything correctly, so it's AMD code, probably also differences in compilers, since I use official DX FXC. The wrapped version has a lot of MOV operations (copies stuff around with no useful contribution).
Last edit: 5 years 4 months ago by Marty McFly.
The following user(s) said Thank You: BeTa, jas01, ChrisG683, Viper_Joe, PureEvilWindom, aaronth07, colesdav

Please Log in or Create an account to join the conversation.

  • aaronth07
More
5 years 4 months ago #13 by aaronth07 Replied by aaronth07 on topic New Contrast Adaptive Sharpening from AMD
A bit off topic, but you said that you ported HBAO+? Is it the same quality as HBAO+ if it was implemented in-game? And how does it compare to MXAO?

Please Log in or Create an account to join the conversation.

  • Qsimil
More
5 years 4 months ago #14 by Qsimil Replied by Qsimil on topic New Contrast Adaptive Sharpening from AMD
He said, but he can't share it due to reshade license issue, even if you are patreon (that's how I understand it, because he didn't reply to my question) ;)

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
5 years 4 months ago - 5 years 4 months ago #15 by Marty McFly Replied by Marty McFly on topic New Contrast Adaptive Sharpening from AMD
Correct, I ported HBAO+ - I even posted screenshots at some point. And yes, I cannot share it to anyone due to its license. It's obvious that I used it as a metric to compare MXAO to it, and it's also obvious that I learned a lot from it. Everyone rates HBAO+ and SSDO very highly but HBAO+ is 2012 tech, SSDO even 2006, everyone learned and improved from them. GTAO (2017 I believe) is superior to every existing screen-space AO tech apart from brute force far field methods, HBAO isn't even close. MXAO non HQ uses the same AO estimator as HBAO+ (which was originally Alchemy SAO), but superior sampling pattern, hence it's easier to filter and requires fewer samples. MXAO HQ is basically GTAO straight after paper, again with optimized sampling and a few other things.
Last edit: 5 years 4 months ago by Marty McFly.
The following user(s) said Thank You: acknowledge, colesdav

Please Log in or Create an account to join the conversation.

  • colesdav
More
5 years 4 months ago #16 by colesdav Replied by colesdav on topic New Contrast Adaptive Sharpening from AMD
Hi, Just wanted to say thanks.

I tested CAS.fx on BFV and compared to Smart_Sharp.fx here:


I wanted to test Metro Exodus on XBOX Game Pass for PC (Beta) but everything seems protected/ encrypted / locked down so I have not found a way to use ReShade.
Metro Exodus with Epic Games Installer is not working with ReShade for me either.

Thanks.

Please Log in or Create an account to join the conversation.

  • aaronth07
More
5 years 4 months ago - 5 years 4 months ago #17 by aaronth07 Replied by aaronth07 on topic New Contrast Adaptive Sharpening from AMD
@colsedav What is smart sharp?
Last edit: 5 years 4 months ago by aaronth07.

Please Log in or Create an account to join the conversation.

  • Viper_Joe
More
5 years 4 months ago #18 by Viper_Joe Replied by Viper_Joe on topic New Contrast Adaptive Sharpening from AMD

aaronth07 wrote: @colsedav What is smart sharp?


github.com/BlueSkyDefender/Depth3D/blob/...aders/Smart_Sharp.fx
The following user(s) said Thank You: aaronth07, someone_for

Please Log in or Create an account to join the conversation.

  • someone_for
More
5 years 4 months ago #19 by someone_for Replied by someone_for on topic New Contrast Adaptive Sharpening from AMD
Wow. SmartSharp has built in CAS and so many more functions. That's definitely the best Sharpening shader out there. Thanks for sharing !

Please Log in or Create an account to join the conversation.

  • jas01
More
5 years 4 months ago #20 by jas01 Replied by jas01 on topic New Contrast Adaptive Sharpening from AMD
Indeed. It's quite hard on the performance tho (if speaking sharpering shaders). CAS is much faster most of the time.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.