(H)ybrid high-(Q)uality (A)nti-(A)liasing (HQAA)
- anontsuki
I'd like to ask however, if you have any intention of making it focus on a depth buffer instead of full screen anti-aliasing? FXAA is great (crazed opinion, I know), but due to its effects on text, kinda sucks to use in text heavy games.
The small samples of lettering in your examples shows a minor modification to text, so it may not be bad, but would love to personally a depth only uh... shader, I guess.
Thanks either way, it's always nice to see new and different takes on aliasing with what we have.
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Significant changes:
- Incorporates adaptive luma color selection in FXAA (defaults to green, but can change to blue or red if it has no green signal)
- Incorporates an in-line sharpen in FXAA before result is returned (this allows HQAA to sharpen only what FXAA runs corrections on)
- Implements use of ReShade standard discard call when FXAA enters its early-exit codepath
- A few other minor optimizations giving HQAAv2.0 slightly better performance than HQAAv1.x
-v2.1: now performs SMAA edge detection using only the Luma detect pass instead of a weighted average of luma and color
-v2.1: modified SMAA luma edge detection to dynamically select either red or green as primary luma instead of using fixed luma weights
-v2.1: clamped output of each AA method to prevent rounding error artifacts (generally very rare, but may improve results when handling exceptionally bright scenes)
Please Log in or Create an account to join the conversation.
- Martigen
I've been waiting to try this, I copied previous versions in but the clashes with SMAA/FXAA and being short on time and using a global shared directory for Reshade shaders, I really didn't want to fluff around with cutting out header files etc so haven't actually seen this working yet -- and so the combined 2.1 release incorporating the head files is a good idea! So I tried it out.
It works.. maybe? I can alter HQAA settings and it's definitely doing something on screen, but I get Reshade errors saying AreaTex and SearchTex cannot be found for HQAA. If I remove HQAA.fx from the shader directory, these disappear and SMAA and FXAA work fine. It seems there is still some kind of clash going on.
In case it helps, as above, I use a global repository for Reshade shaders and texture files -- that is, I have one install of these and when I install Reshade to a game, I just copy the .dll and the .ini file that points to these directories. This way I have one set of shaders and texture files for all games on the system, instead of dozens of separate installations. The directories are specified in Reshade's settings and so far all shaders and configs work fine with this.
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Edit - v2.2.1 pushed. SMAA edge detection settings recalibrated taking advantage of the new adaptive luma detection code, resulting in less blur and better retention of details in the original scene.
Please Log in or Create an account to join the conversation.
- Martigen
11:06:24:740 [13720] | INFO | Loading image files for textures ...
11:07:19:814 [08908] | INFO | Successfully loaded "M:\Reshade\Shaders\AdaptiveSharpen.fx".
11:07:19:817 [11788] | INFO | Successfully loaded "M:\Reshade\Shaders\Clarity2.fx".
11:07:19:825 [00824] | INFO | Successfully loaded "M:\Reshade\Shaders\HQAA.fx".
11:07:19:827 [00032] | INFO | Successfully loaded "M:\Reshade\Shaders\PD80_02_Bloom.fx".
11:07:20:007 [13720] | INFO | Loading image files for textures ...
11:07:20:008 [13720] | ERROR | Source "AreaTex.png" for texture 'V__areaTex' could not be found in any of the texture search paths!
11:07:20:008 [13720] | ERROR | Source "SearchTex.png" for texture 'V__searchTex' could not be found in any of the texture search paths!
The relevant portion of the config file:
[GENERAL]
CurrentPreset=0
EffectSearchPaths=m:\reshade\shaders
FontGlobalScale=2.000000
IntermediateCachePath=M:\Temp
NoReloadOnInit=0
PerformanceMode=0
PresetPath=.\ReShadePreset.ini
PresetTransitionDelay=1000
SaveWindowState=1
ScreenshotFormat=1
ScreenshotPath=.
ShowClock=0
ShowFPS=1
SkipLoadingDisabledEffects=1
TechniqueSorting=MXAO,LumaSharpen,AdaptiveSharpen,FXAA,SMAA,Clarity,Vibrance,AmbientLight,DisplayDepth,DPX
TextureSearchPaths=m:\reshade\textures
TutorialProgress=4
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Sometimes I feel like I'm iterating versions too fast, but I always have a game open with the shader live and running while I'm messing with it... hard to argue with good results when that's what the game keeps showing me.
Edit: fix is now pushed as version 2.4.1. It uses unique names for all textures, samplers, pixel shaders, and vertex shaders, which should hopefully make it actually 100% compatible with SMAA and FXAA.
Please Log in or Create an account to join the conversation.
- Martigen
Tried out 2.4.1, same issue:
15:10:13:298 [11376] | INFO | Successfully loaded "M:\Reshade\Shaders\AdaptiveSharpen.fx".
15:10:13:300 [14800] | INFO | Successfully loaded "M:\Reshade\Shaders\Clarity2.fx".
15:10:13:303 [12376] | INFO | Successfully loaded "M:\Reshade\Shaders\PD80_02_Bloom.fx".
15:10:13:311 [09796] | INFO | Successfully loaded "M:\Reshade\Shaders\SMAA.fx".
15:10:13:312 [10764] | INFO | Successfully loaded "M:\Reshade\Shaders\HQAA.fx".
15:10:13:521 [11896] | INFO | Loading image files for textures ...
15:10:13:536 [11896] | ERROR | Source "AreaTex.png" for texture 'V__HQAAareaTex' could not be found in any of the texture search paths!
15:10:13:547 [11896] | ERROR | Source "SearchTex.png" for texture 'V__HQAAsearchTex' could not be found in any of the texture search paths!
I also noticed that ASSMA.fx was complaining -- I think that's your shader too? -- so I removed it from the shader directory. No dice unfortunately, the above errors are with ASSMA.fx removed. When it was in the shader directory, I got twice the number of complaints.
Is it worth copying the .png texture files to reference your own versions?
EDIT: I just tested giving the game its own shader and texture repository, and copying only SMAA, FXAA and HQAA across (and the associated textures to the textures dir). Same error. I then removed SMAA and FXAA but kept their .fxh header files present. Same error. Then I removed the header files as a test (I presume these are needed though) so HQAA is the only shader present now (note this means only HQAA.fx, Resahde.fxh, and ReshadeUI.fxh are in the shader directory). Same error. :0
Â
Please Log in or Create an account to join the conversation.
- Martigen
My shader respository has been built over years, and while I do regularly keep it up to date, it includes shaders from lots of sources in the one directory including shaders not in any of the official repositories. So I decided to do a test with a clean install of Reshade to a game and download all of (and only) those shaders the installer provides, then copied HQAA across -- and it works with no errors.
So it's something particular to my Shaders directory, perhaps another shader is causing this even without being loaded. I'll narrow it down to find what's going on, but don't make any further changes on my account unless it's something you want to do anyway.
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Edit: just tried it myself to make sure I didn't do something that caused a weird problem. Installed it to a random game, placed a checkmark in the SweetFX package to pull the textures, and then dropped HQAA.fx in the shaders folder.
00:06:40:724 [13684] | INFOÂ | Registering hooks for "user32.dll" ...
00:06:40:725 [13684] | INFOÂ | > Libraries loaded.
00:06:40:725 [13684] | INFOÂ | > Found 14 match(es). Installing ...
00:06:40:759 [13684] | INFOÂ | Registering hooks for "ws2_32.dll" ...
00:06:40:759 [13684] | INFOÂ | > Libraries loaded.
00:06:40:760 [13684] | INFOÂ | > Found 8 match(es). Installing ...
00:06:40:793 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\d2d1.dll" ...
00:06:40:794 [13684] | INFOÂ | > Delayed.
00:06:40:794 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\d3d9.dll" ...
00:06:40:794 [13684] | INFOÂ | > Delayed until first call to an exported function.
00:06:40:794 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\d3d10.dll" ...
00:06:40:795 [13684] | INFOÂ | > Delayed.
00:06:40:795 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\d3d10_1.dll" ...
00:06:40:796 [13684] | INFOÂ | > Delayed.
00:06:40:796 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\d3d11.dll" ...
00:06:40:797 [13684] | INFOÂ | > Delayed.
00:06:40:797 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\d3d12.dll" ...
00:06:40:798 [13684] | INFOÂ | > Delayed.
00:06:40:798 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\dxgi.dll" ...
00:06:40:798 [13684] | INFOÂ | > Libraries loaded.
00:06:40:798 [13684] | INFOÂ | > Found 5 match(es). Installing ...
00:06:40:830 [13684] | INFOÂ | Registering hooks for "C:\WINDOWS\system32\opengl32.dll" ...
00:06:40:830 [13684] | INFOÂ | > Delayed.
00:06:40:830 [13684] | INFOÂ | Initialized.
00:06:40:833 [13684] | INFOÂ | Redirecting Direct3DCreate9(SDKVersion = 32) ...
00:06:40:837 [13684] | INFOÂ | Installing export hooks for "C:\WINDOWS\system32\d3d9.dll" ...
00:06:40:837 [13684] | INFOÂ | > Found 9 match(es). Installing ...
00:06:41:402 [13684] | INFOÂ | Redirecting IDirect3D9::CreateDevice(this = 005C9640, Adapter = 0, DeviceType = 1, hFocusWindow = 0030048A, BehaviorFlags = 0x44, pPresentationParameters = 0BC70010, ppReturnedDeviceInterface = 0BC70048) ...
00:06:41:405 [13684] | INFOÂ | > Dumping presentation parameters:
00:06:41:405 [13684] | INFOÂ |Â Â +
+
+
00:06:41:405 [13684] | INFO |  | Parameter                              | Value                                  |
00:06:41:405 [13684] | INFOÂ |Â Â +
+
+
00:06:41:406 [13684] | INFO |  | BackBufferWidth                        | 1920                                   |
00:06:41:406 [13684] | INFO |  | BackBufferHeight                       | 1080                                   |
00:06:41:406 [13684] | INFO |  | BackBufferFormat                       | D3DFMT_A8R8G8B8                        |
00:06:41:406 [13684] | INFO |  | BackBufferCount                        | 1                                      |
00:06:41:406 [13684] | INFO |  | MultiSampleType                        | 0                                      |
00:06:41:407 [13684] | INFO |  | MultiSampleQuality                     | 0                                      |
00:06:41:407 [13684] | INFO |  | SwapEffect                             | 1                                      |
00:06:41:407 [13684] | INFO |  | DeviceWindow                           | 0030048A                               |
00:06:41:407 [13684] | INFO |  | Windowed                               | FALSE                                  |
00:06:41:407 [13684] | INFO |  | EnableAutoDepthStencil                 | TRUE                                   |
00:06:41:408 [13684] | INFO |  | AutoDepthStencilFormat                 | 75                                     |
00:06:41:408 [13684] | INFO |  | Flags                                  | 0x1                                    |
00:06:41:408 [13684] | INFO |  | FullScreen_RefreshRateInHz             | 0                                      |
00:06:41:408 [13684] | INFO |  | PresentationInterval                   | 0x80000000                             |
00:06:41:408 [13684] | INFOÂ |Â Â +
+
+
00:06:42:317 [13684] | INFOÂ | Running on NVIDIA GeForce RTX 2060 Driver 497.9
00:06:42:321 [13684] | INFOÂ | Recreated runtime environment on runtime 0C8297A8.
00:06:42:398 [08292] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\CAS.fx".
00:06:42:409 [03832] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Technicolor2.fx".
00:06:42:409 [05896] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Vibrance.fx".
00:06:42:409 [06712] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Monochrome.fx".
00:06:42:410 [10844] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\LiftGammaGain.fx".
00:06:42:410 [14092] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\FakeHDR.fx".
00:06:42:410 [13800] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Deband.fx".
00:06:42:413 [00860] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\ASCII.fx".
00:06:42:414 [08292] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\ChromaticAberration.fx".
00:06:42:418 [06112] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\CRT.fx".
00:06:42:427 [03832] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Tonemap.fx".
00:06:42:427 [10844] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\LumaSharpen.fx".
00:06:42:437 [05896] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Vignette.fx".
00:06:42:439 [14092] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\FilmGrain.fx".
00:06:42:441 [00860] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Border.fx".
00:06:42:442 [13800] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\DisplayDepth.fx".
00:06:42:443 [06112] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Curves.fx".
00:06:42:443 [10844] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\LUT.fx".
00:06:42:449 [06112] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Daltonize.fx".
00:06:42:449 [11764] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\SMAA.fx".
00:06:42:451 [08292] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\ColorMatrix.fx".
00:06:42:454 [00860] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Cartoon.fx".
00:06:42:455 [03832] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\UIMask.fx".
00:06:42:455 [06712] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Nostalgia.fx".
00:06:42:459 [13800] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\DPX.fx".
00:06:42:462 [02308] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\HQAA.fx".
00:06:42:463 [11764] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Splitscreen.fx".
00:06:42:467 [06712] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Sepia.fx".
00:06:42:473 [02308] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Layer.fx".
00:06:42:474 [11764] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Technicolor.fx".
00:06:42:479 [14092] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\FXAA.fx".
00:06:42:483 [02308] | INFOÂ | Successfully loaded "\Steam\steamapps\common\Duke Nukem Forever\System\reshade-shaders\Shaders\Levels.fx".
00:06:44:624 [13684] | INFOÂ | Loading image files for textures ...
00:07:34:925 [13684] | INFOÂ | Destroyed runtime environment on runtime 0C8297A8.
00:07:35:015 [13684] | INFOÂ | Exiting ...
00:07:35:017 [13684] | INFOÂ | Uninstalling 41 hook(s) ...
00:07:36:087 [13684] | INFOÂ | Finished exiting.
2nd edit - I'm glad it's some sort of conflict other than the actual shader, that would have given me nightmares trying to sort out. I do think you pointed out a real flaw with my attempt at compatibility above though, the fact that it was naming and referencing the textures internally using the stock SMAA and FXAA code was likely going to cause hiccups for someone at some point.
Please Log in or Create an account to join the conversation.
- Martigen
Now for some feedback: I really like how it picks up on edges and smoothes them out where SMAA wouldn't (and which was always an advantage of FXAA I found) so congrats there. It definitely has an impact on UI text, particularly if it's small but I don't think there's much to be done there. It's quite soft and definitely needs a sharper after it.
However, an idea -- and I may be speaking out of my ass since I am not a shader developer -- but I've seen some shaders blend the result of their work with a scene based off a strength slider. Currently the two tunables cover edge detection level and subpixels, but is there merit in being able to control how strong the overall effect is by blending? It might allow to smooth edges like those SMAA misses (with a tradeoff based on strength) while minimising impact on text. Or not, again, my ass is talking.
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Edit: I'll try fiddling with the inline sharpen I use in the FXAA pass(es) also. I set it up to be fairly conservative, but there might be room to make it stronger since it only affects output from FXAA.
Yet more edit: Please don't be shy with ideas, you don't necessarily need to understand the code for an idea to be good. I welcome feedback both positive and negative as long as it's constructive.
I posted a forked experimental version with a completely different method of calculating the sharpening amount used by the FXAA inline sharpen, find it here . The results look somewhat better to me in my own testing, but the changes are very minor at best, so I'm going to need feedback to decide whether to tweak it further, implement as-is, or just go back to the old method.
Updated the experimental fork since last edit. New experimental version computes sharpening amount based on perceived luminance of the two color channels not selected to represent luma during FXAA edge detection and correction. Results look good to me, it seems to interact less with fine UI elements, leaving them more readable.
Updated experimental fork again (v2.5 this time). This one will likely merge to main branch. I realized the new calculation could return a negative value on very dark pixels so I clamped it to positive numbers. Since this is likely to happen a lot in dark scenes I also implemented an early exit path in FXAA which skips the sharpening calculations entirely if calculated sharpening requirement = 0. Didn't think it'd amount to much but I noted an execution time drop of about 0.1ms on the GPU after the changes, which is more than I expected.
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Please Log in or Create an account to join the conversation.
- NoPippinNo
On the subject of text artifacting, I accidentally noticed that something like a very sharp Bumpmapping shader before HQAA cleaned texts up a fair bit for me, though admittedly it probably varies with game fonts and such.
Is there such a thing as a text reinforcement shader out there? (the advantage of a separate shader being hotkeys)
I remember another AA shader having an option using specific color regions to avoid processing text but maybe reinforcing it would yield better results?
I'm a total layman on the inner workings of shaders so if you already do something like this internally please disregard this >.<
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Edit: you got me looking at it a bit to see if I could improve it and I ended up devising a new method of calculating the inline sharpening for the FXAA routine. It interacts a lot more cleanly with UI elements and fine details than I'd managed to make it do before. Pushed it as v2.8.2.
Please Log in or Create an account to join the conversation.
- NoPippinNo
I wonder if a narrow range around specific HSV values could be subdued/excluded from the processing?
Font colors might be something fairly easy to mod in many games, and some particularly hard-to-read HSV values can be very specific to "vanilla" text like colors used on loot rarity in various games
If a preset maker had a few fields to input those values on you could offer an extremely accurate filter for almost any game!
In the modded font scenario even what used to be black and white fonts could be slightly tuned with precise hues for filtering
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
Please Log in or Create an account to join the conversation.
- Martigen
On the presets, not sure how hover tips work, but is it possible to list the settings when you hover over each preset? I noticed also that Custom, along with the defaults, looks different from all the presets so we technically have five presets to choose from at the moment and it'd be good to see what values they're using to better understand how to tune it.
Please Log in or Create an account to join the conversation.
- lordbean
- Topic Author
The actual presets follow a similar mindset to the ones that can be triggered by a #define in SMAA - even the Ultra preset still isn't as sensitive or aggressive as the shader can go, especially if you enable Virtual Photography mode.
That reminds me - v2.9 had a change to Virtual Photo mode I forgot to list. When enabled, Virtual Photo mode disables FXAA's inline sharpen entirely so that there's no artifacts generated by it. The math I'm doing for the sharpen amount is working fairly well in probably 95-98% of scenarios, but it produces the odd artifact now and then on the remaining couple percent.
Please Log in or Create an account to join the conversation.