Author Topic: FXAA antialiasing shader injection/ hook for DX9/10/11 based games (Update)  (Read 13781 times)

0 Members and 1 Guest are viewing this topic.

Offline Delusianne

  • Peasant
  • *
  • Renown: 8
  • Infamy: 3
  • cRPG Player
    • View Profile
  • Game nicks: Wolves_Delusianne, Delu, Delusianne, Crux
Heya folks,

I posted this over at the steam forums, also being part of of the below mentioned thread (all props to "some dude" who came up with this solution, and also BeetleatWar1977 working on direct shader implementation in general and last but not least Timothy Lottes at Nvidia for giving us FXAA in the first place, I was merely pushing and analyzing on topic, cross referencing known stuff and issues to gain the needed attention and get the real smart folks together to get it going) and just thought this might be nice for a lot of ppl especially if you already suffer from performance issues with warband (or at least running cRPG) and maybe also in other games but still would like to use some form of AA. So here it goes:

just wanted to let you know about this awesome stuff, keep in mind tho it might cause troubles in Steam/VAC/ punkbuster/ GFWL anti cheat enabled Games (as false positives, so could in that case get one banned or even make your babies cry), so maybe stay away from those for now (not the babies tho).

Confirmed to work in a lot of DX9 and now even in some DX10/ 11 games.

You have no idea what this actually does? read this:
Performance/ Quality trade off is quite good (especially compared to more traditional power hungry antialiasing methods moreso on systems which can't handle those very well without performance issues). If you come across any issues/ bugs, please report them in this thread as detailed as possible (so post your system specs, a description of the issue and upload some screenhots).

Quote from: Gast;8862131
Hi, I'm some dude and just wanted to see how fxaa looks on my notebook. But oh noes, I have only two old games and both use d3d9.
So instead of complaining I wrote some code and play those games with fxaa
now. It's faster than with the aa provided by the games.

Quote from: Crux;8862282
@some dude
thx for providing your work on fxaa injection, basically we were (well it's really all User BeetleatWar1977, props to him) trying to figure out how to make it work with games based on an UE3 Engine for starters (partly because of the freely accessible shaders, I brought up the topic because I had noticed some time ago that really most compatibility AA bit modes remove/ disable some ingame effects/ shaders so if FXAA would be useable that wouldn't be an issue anymore and maybe combined with higher res downsampling be almost as "perfect" as it could get).

While I lack the background to do much with it (shader code/ing), it's good some ppl do know a thing or two about it but it also seems to need ppl asking the right questions and/ or getting some attention of those who can actually figure this out, really took me by surprise this potential seemed largely undiscovered/ gone unnoticed, not just on the topic of FXAA but shaders tweaking in general, with so many enthusiast and talented game modders/ devs around. That's kinda my part so far, pushing for it and asking questions for some really smart ppl to figure it out. A few pages back I posted what Timothy Lottes from Nvidia answered to a quick question about FXAA injection, while he kept it short he described a quick and dirty implementation. Not sure if it might be of any use to you as you and BeetleatWar1977 might have already surpassed this from the looks of it but it'd be cool if you'd stay around!

Quote from: Gast;8847919
Timothy Lottes said...

"might be possible to quickly prototype FXAA in a GL or DX11 game which provides editable shaders. You would need to find a late-in the-frame post processing shader which samples each pixel once, then run FXAA to "sample the pixel" with FXAA_GREEN_AS_LUMA and use in-pixel-shader texture size queries to produce the required inputs to FXAA (so DX9 is likely out). This would NOT be the correct way to integrate FXAA, but might work."

----- http://www.forum-3dcenter.org/vbulletin/showthread.php?p=8869098#post8869098

While this is a German forum (all is also explained in english) english speaking guests are greatly welcome (no registration necessary to post on this part of the forums).
Give it a try it's really sweet.

But please keep this in mind besides the fact that it is work in progress on a lot of ends:
Quote from: Timothy Lottes
Without FXAA's Pixel and Sub-Pixel Contrast Reduction, visually aliasing still remains. With FXAA, aliasing is much reduced and consistent across image features. No post-process AA filter is going to fix everything, there is always a compromise between sharpness and lack of aliasing, but I feel as if FXAA does a good job and has a great quality/cost ratio.

Certainly some developers and users will have different preferences on the aliasing vs softness trade-off. For this FXAA 3.9 Quality algorithm has a tuning knob: FXAA_QUALITY__SUBPIX. The "No Contrast Reduction" images were produced by zeroing this tuning knob.


-----

04 August 2011 - Beta 8 of the hook:
Quote from: Gast;8869029
[some dude] Minor changes in d3d9 mode, no changes in d3d10 (due to no bugreports with small demos and my lack of d3d11 hardware). Additionally I gave Anarki_Hunter's suggestion some attention. Beta 7 gives you the possibility to add a sharpening pass [you don't have to bother with this at all for now- delu] in DirectX 9 prior to fxaa execution. The readme contains how.

Quote from: Gast;8869098
[some dude]
Sorry guys, I tried to consider all the different game engines I encountered so far and sometimes a new version creates and breaks compatibilities at the same time. [talking about the 1 pack for 3 renderpath hook approach for lots of games]

However, I think to have found a good solution for the "darkness" problem which also fixes Crysis 1 -dx9 (Thanks Ronny145). From how I expect GTA4's engine to work, it also may fix the lights.

http://www.forum-3dcenter.org/vbulletin/showthread.php?p=8869098#post8869098

Don't expect much from the sharpening pass. I just took some random sharpen shader and did not tune any parameters. You can experiment with own sharpening shaders if you can work with hlsl. Let me know if there is a good one.


beta version 8 notes

beta version 8! directx 9, directx 10, directx 11, x86 binaries only! may be incompatible with any other form of antialiasing! can be combined with downsampling!

Install:
If the game uses DirectX 9, put all files from the d3d9 directory into the directory containing the game executable.
If the game uses DirectX 10/11, put all files from the d3d10 directory into the directory containing the game executable.

Uninstall: Remove the files.

Notes:
Do not mix d3d9 and d3d10 the files.
Install the latest DirectX runtime.
A "log.log" file is created to log behaviour/ bugs.
If the "log.log" file is not created then you use the wrong "*.dll" or you put it into the wrong directory.
If the "log.log" is created but the game crashes or FXAA is disabled, look where the "log.log" is created. Usually the shader files go into that particular directory.
Try to put the files into different directories before saying it doesn't work.
In some games (e.g. Portal 1 or Halo 1) refuse to accept the alpha channel. A general workaround (lower quality) for those is to add the following line at the beginning of shader.fx :
#define FXAA_GREEN_AS_LUMA 1
There is a way to experiment with sharpening. I added an example. To activate additional sharpening filter change edit the line "//Replace this line with #include "Sharpen.h" to add a sharpening pass" in shader.fx.
Note that right now sharpening is only an example that it can be done. I more-or-less copypasted a random sharpen filter to show how my mod can be modded.


Keys:
Insert : Enable/Disable FXAA
Del : Screenshot
« Last Edit: August 05, 2011, 08:04:37 pm by Delusianne »

Offline Christo

  • Dramaturge
  • King
  • **********
  • Renown: 1844
  • Infamy: 371
  • cRPG Player
    • View Profile
  • Faction: No faction, methinks.
  • Game nicks: Sir_Christo, Christo, Cristo.
  • IRC nick: Christo
Re: FXAA shader injection/ hook for DX9 based games
« Reply #1 on: August 01, 2011, 05:58:47 pm »
+1
Hmm, thanks for posting, I'll try this out.
visitors can't see pics , please register or login

                                                                                            Thanks to cmpxchg8b for the picture!

Offline Baggy

  • Count
  • *****
  • Renown: 199
  • Infamy: 94
  • cRPG Player
  • Sup brah
    • View Profile
  • Faction: Fallen Brigade
  • Game nicks: Baggy _Potato Blight_ Famine Emigration
  • IRC nick: Baggy
Re: FXAA shader injection/ hook for DX9 based games
« Reply #2 on: August 01, 2011, 06:02:11 pm »
+1
Gojng to see if this works.
visitors can't see pics , please register or login

Offline Christo

  • Dramaturge
  • King
  • **********
  • Renown: 1844
  • Infamy: 371
  • cRPG Player
    • View Profile
  • Faction: No faction, methinks.
  • Game nicks: Sir_Christo, Christo, Cristo.
  • IRC nick: Christo
Re: FXAA shader injection/ hook for DX9 based games
« Reply #3 on: August 01, 2011, 06:28:11 pm »
+1
I tested it, but only at native.

It has a slight AA effect on my game, but it's worth it for me, for the extra FPS.

Is there a way to enhance the effect a bit more though? I'm kinda satisfied with it right now, just curious.
visitors can't see pics , please register or login

                                                                                            Thanks to cmpxchg8b for the picture!

Offline Delusianne

  • Peasant
  • *
  • Renown: 8
  • Infamy: 3
  • cRPG Player
    • View Profile
  • Game nicks: Wolves_Delusianne, Delu, Delusianne, Crux
Re: FXAA shader injection/ hook for DX9 based games
« Reply #4 on: August 01, 2011, 06:32:25 pm »
0
Hey glad it is helping. Well there is lots of stuff you can tweak but most would require you to really look closer into the shader file, but it's well explained/ commented inside, if that one seemed a bit too toned down to you and you don't want to edit the settings manually you can test his beta 2 with the additional updated shader file he provided a few post later (based on feedback he toned it down).

http://www.forum-3dcenter.org/vbulletin/showthread.php?p=8862388#post8862388 beta2 (outdated, but may be usefull for quick tests as mentioned above; but only use combined with the file from the link below)

http://www.forum-3dcenter.org/vbulletin/showthread.php?p=8862432#post8862432
« Last Edit: August 01, 2011, 06:41:23 pm by Delusianne »

Offline Christo

  • Dramaturge
  • King
  • **********
  • Renown: 1844
  • Infamy: 371
  • cRPG Player
    • View Profile
  • Faction: No faction, methinks.
  • Game nicks: Sir_Christo, Christo, Cristo.
  • IRC nick: Christo
Re: FXAA shader injection/ hook for DX9 based games
« Reply #5 on: August 01, 2011, 06:34:05 pm »
+1
Hey glad it is helping. Well there is lots of stuff you can tweak but most would require you to really look closer into the shader file, but it's well explained/ commented inside, if that one seemed a bit too toned down to you and you don't want to edit the settings manually you can test his beta 2 with the additional updated shader file he provided a few post later (based on feedback he toned it down).

Oh. Well I'm happy with this effect, I can run the game without 4XAA and it doesn't look like total garbage.  8-)
visitors can't see pics , please register or login

                                                                                            Thanks to cmpxchg8b for the picture!


Offline Delusianne

  • Peasant
  • *
  • Renown: 8
  • Infamy: 3
  • cRPG Player
    • View Profile
  • Game nicks: Wolves_Delusianne, Delu, Delusianne, Crux
Re: FXAA shader injection/ hook for DX9 based games
« Reply #7 on: August 01, 2011, 08:15:54 pm »
0

Offline Delusianne

  • Peasant
  • *
  • Renown: 8
  • Infamy: 3
  • cRPG Player
    • View Profile
  • Game nicks: Wolves_Delusianne, Delu, Delusianne, Crux
Re: FXAA shader injection/ hook for DX9 based games
« Reply #8 on: August 02, 2011, 01:00:37 am »
0
Feedback anyone else? If you like and plan to use this, feedback helps to get it even further and make it better.
If not u can't expect as much or it even could die out quickly (if it's dev loses interest due lack of feedback or get's the impression no one's interested).
So plz don't just sit in the dark and hope this keeps going all by itself.
« Last Edit: August 02, 2011, 01:35:28 am by Delusianne »

Offline Tydeus

  • King
  • **********
  • Renown: 1422
  • Infamy: 351
  • cRPG Player A Gentleman and a Scholar
  • Item re-unbalance guy
    • View Profile
  • Game nicks: Tydeus
  • IRC nick: Tydeus
Re: FXAA shader injection/ hook for DX9 based games
« Reply #9 on: August 02, 2011, 12:43:00 pm »
0
Looked nice, but unfortunately while my fps was nearly untouched by enabling it, I started getting some "jitters" on a few maps which made it unusable.
chadz> i wouldnt mind seeing some penis on my character

Offline Delusianne

  • Peasant
  • *
  • Renown: 8
  • Infamy: 3
  • cRPG Player
    • View Profile
  • Game nicks: Wolves_Delusianne, Delu, Delusianne, Crux
Re: FXAA shader injection/ hook for DX9 based games
« Reply #10 on: August 02, 2011, 03:28:54 pm »
0
Looked nice, but unfortunately while my fps was nearly untouched by enabling it, I started getting some "jitters" on a few maps which made it unusable.

What are your system specs?

Offline KaMiKaZe_JoE

  • Marshall
  • ********
  • Renown: 904
  • Infamy: 117
  • cRPG Player
    • View Profile
  • Faction: Cavalieres
  • Game nicks: KaMiKaZe _______
Re: FXAA shader injection/ hook for DX9 based games
« Reply #11 on: August 02, 2011, 03:56:56 pm »
+1
Don't trust--probably witchcraft.
"I don't think I'd want to meet anyone from cRPG. Sorry no offense lol" -TG

Offline Nessaj

  • King
  • **********
  • Renown: 1399
  • Infamy: 176
  • cRPG Player Madam Black Queen A Gentleman and a Scholar
  • ▃ ▅ ▅ ▅ ▄ ▅ ▇ ▅ ▄ ▅ ▇
    • View Profile
    • Vanguard
  • Faction: Vanguard
  • Game nicks: Vanguard_Cooties
  • IRC nick: Nessaj
Re: FXAA shader injection/ hook for DX9 based games
« Reply #12 on: August 02, 2011, 05:41:34 pm »
0
Looks great but the potential issues with anti-cheat programs are what keeps me away from it.

Otherwise would love to use it really, the edges looks MUCH better.
Things don't exist simply because you believe in them, thus sayeth the almighty creature in the sky!

Offline Delusianne

  • Peasant
  • *
  • Renown: 8
  • Infamy: 3
  • cRPG Player
    • View Profile
  • Game nicks: Wolves_Delusianne, Delu, Delusianne, Crux
Re: FXAA shader injection/ hook for DX9 based games
« Reply #13 on: August 02, 2011, 06:38:41 pm »
0
Looked nice, but unfortunately while my fps was nearly untouched by enabling it, I started getting some "jitters" on a few maps which made it unusable.

Just noticed this too after some more testing, maybe it's related to vsync or well playing without vsync, not sure really. Gonna try a few things but also already reported it.

Looks great but the potential issues with anti-cheat programs are what keeps me away from it.

Yep understandable, but as mentioned before if you don't play on a Warband server with VAC enabled (there don't really seem to be many if any at all) it should be safe to use.
« Last Edit: August 02, 2011, 07:13:09 pm by Delusianne »

Offline Baggy

  • Count
  • *****
  • Renown: 199
  • Infamy: 94
  • cRPG Player
  • Sup brah
    • View Profile
  • Faction: Fallen Brigade
  • Game nicks: Baggy _Potato Blight_ Famine Emigration
  • IRC nick: Baggy
Re: FXAA shader injection/ hook for DX9 based games
« Reply #14 on: August 03, 2011, 12:56:44 am »
0
Warband dosnt support VAC.
visitors can't see pics , please register or login