NVIDIA's New FXAA Antialiasing Technology @ [H]

Hexen525

Limp Gawd
Joined
Feb 20, 2007
Messages
186
I tested the FXAA in DNF and I was less than impressed. Blurred odd spots of the screen and I still had a lot of aliasing issues.
 

socK

Supreme [H]ardness
Joined
Jan 25, 2004
Messages
4,230
I prefer traditional AA. I haven't used FXAA, but I have used MLAA, and I find it to blur my games in a negative manner... not to mention making text look horrible. It all comes down to loss of data in my opinion. Less raw data = less image quality. Applying algorithms and filters to predict what is supposed to be there just isn't accurate, and as the complexity and fidelity of game engines increases, AA methods will look more and more incorrect. I enjoy my 6870x2 setup but not MLAA.

p.s. when did the EDIT button get added !?

Because driver MLAA uses the entire, complete image, when the game implements it they can just do it before the 2d part.

I tested the FXAA in DNF and I was less than impressed. Blurred odd spots of the screen and I still had a lot of aliasing issues.

Might have been using an old version. Look how fast the guy churns out new ones. I think the dev said FEAR 3 was using the first version of the shader... ancient by what he's up to now.
 

blandead

Limp Gawd
Joined
Nov 6, 2010
Messages
306
Try mixing AMD's CFAA and 2xEQAA, and/or Adaptive MSAA I barely see any performance hit and I get good AA and IQ increase. I haven't played around with MLAA, because like this article pointed out the performance penalty isn't worth it unless you get full developer support to maximize it's effects by applying it only when it's worth it. One thing is for sure, with actual competition us consumers are finally getting some improvements on both sides. I hope AMD/NVIDIA both answer back with something else and continues this process because either way we are seeing better performance for our dollar. Hopefully next-gen cards have higher memory speed and bandwidth so there's less of an impact which AA method to use.
 

hierovision

Limp Gawd
Joined
Oct 18, 2010
Messages
143
There's a lot of back-and-forth bullshit when it comes to AA. FXAA, I think, is the first step towards companies considering what's best for gamers instead of what's best for themselves. Instead of trying to make the other guy look bad by using algorithms they know make their competitor's cards struggle, they're trying to give US (gamers) the best possible solution.

Imagine, for a second, how awesome our world would be if they worked together on a few key technologies... ok I'm going to stop dreaming now.
 

DAOWAce

Limp Gawd
Joined
Apr 8, 2007
Messages
139
When I played the Duke Nukem Forever demo, FXAA destroyed the FPS for some reason.

Moved it back to FSAA and FPS shot up majorly.

Have yet to try this on the full game, because, well, it sucked.

Still, FXAA looked very promising, but I also thought there was a CON as it's less effective in motion, or there was more blurring.. or something.
 

Pieter3dnow

Supreme [H]ardness
Joined
Jul 29, 2009
Messages
6,784
There's a lot of back-and-forth bullshit when it comes to AA. FXAA, I think, is the first step towards companies considering what's best for gamers instead of what's best for themselves. Instead of trying to make the other guy look bad by using algorithms they know make their competitor's cards struggle, they're trying to give US (gamers) the best possible solution.

Imagine, for a second, how awesome our world would be if they worked together on a few key technologies... ok I'm going to stop dreaming now.

The problem is it has to be implemented, that is additional development time which is expensive.
 

GoodBoy

2[H]4U
Joined
Nov 29, 2004
Messages
2,281
The problem is it has to be implemented, that is additional development time which is expensive.

Doesn't appear too difficult to add:

Already been done for the most part. Someone has already ported the FXAA shader to be used in ENBseries. It works in GTA4. That's right, you can have FXAA in GTA4, which has zero support for MSAA.

Look ma, no jaggies!
GTAIV2011-07-1706-04-26-34.jpg



This code snippet can be pasted into ENBseries' effect.txt to add the shader effect.
Code:
/*============================================================================
   FXAA3 QUALITY - PC
 	NVIDIA FXAA III.8 by TIMOTHY LOTTES
============================================================================*/

   #define FXAA_LINEAR 0
   #define FXAA_QUALITY__EDGE_THRESHOLD (1.0/16.0)
   #define FXAA_QUALITY__EDGE_THRESHOLD_MIN (1.0/16.0)
   #define FXAA_QUALITY__SUBPIX_CAP (3.0/4.0)
   #define FXAA_QUALITY__SUBPIX_TRIM (1.0/4.0)
   #define FXAA_QUALITY__SUBPIX_TRIM_SCALE  (1.0/(1.0 - FXAA_QUALITY__SUBPIX_TRIM))
   #define FXAA_SEARCH_STEPS     8
   #define FXAA_SEARCH_THRESHOLD (1.0/4.0)

float4 FxaaPixelShader(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{   

#define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))
#define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))

float2 pos = IN.txcoord.xy;

float2 rcpFrame = float2(1/ScreenSize, ScreenScaleY/ScreenSize);
float4 rcpFrameOpt = float4(2/ScreenSize, 2*ScreenScaleY/ScreenSize, 0.5/ScreenSize, 0.5*ScreenScaleY/ScreenSize);

float lumaN = dot(FxaaTexOff(SamplerColor, pos.xy, float2(0, -1), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));
float lumaW = dot(FxaaTexOff(SamplerColor, pos.xy, float2(-1, 0), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));


float4 rgbyM;
rgbyM.xyz = FxaaTexTop(SamplerColor, pos.xy).xyz;
rgbyM.w = dot(rgbyM.xyz, float3(0.299, 0.587, 0.114));
float lumaE = dot(FxaaTexOff(SamplerColor, pos.xy, float2( 1, 0), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));
float lumaS = dot(FxaaTexOff(SamplerColor, pos.xy, float2( 0, 1), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));
float lumaM = rgbyM.w;


float rangeMin = min(lumaM, min(min(lumaN, lumaW), min(lumaS, lumaE)));
float rangeMax = max(lumaM, max(max(lumaN, lumaW), max(lumaS, lumaE)));
float range = rangeMax - rangeMin;

if(range < max(FXAA_QUALITY__EDGE_THRESHOLD_MIN, rangeMax * FXAA_QUALITY__EDGE_THRESHOLD)) return rgbyM;


float lumaNW = dot(FxaaTexOff(SamplerColor, pos.xy, float2(-1,-1), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));
float lumaNE = dot(FxaaTexOff(SamplerColor, pos.xy, float2( 1,-1), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));
float lumaSW = dot(FxaaTexOff(SamplerColor, pos.xy, float2(-1, 1), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));
float lumaSE = dot(FxaaTexOff(SamplerColor, pos.xy, float2( 1, 1), rcpFrame.xy).xyz, float3(0.299, 0.587, 0.114));



float lumaL = (lumaN + lumaW + lumaE + lumaS) * 0.25;
float rangeL = abs(lumaL - lumaM);
float blendL = saturate((rangeL / range) - FXAA_QUALITY__SUBPIX_TRIM) * FXAA_QUALITY__SUBPIX_TRIM_SCALE; 
blendL = min(FXAA_QUALITY__SUBPIX_CAP, blendL);

float edgeVert = abs(lumaNW + (-2.0 * lumaN) + lumaNE) + 2.0 * abs(lumaW  + (-2.0 * lumaM) + lumaE ) + abs(lumaSW + (-2.0 * lumaS) + lumaSE);
   	float edgeHorz = abs(lumaNW + (-2.0 * lumaW) + lumaSW) + 2.0 * abs(lumaN  + (-2.0 * lumaM) + lumaS ) + abs(lumaNE + (-2.0 * lumaE) + lumaSE);
   	bool horzSpan = edgeHorz >= edgeVert;

float lengthSign = horzSpan ? -rcpFrame.y : -rcpFrame.x;
if(!horzSpan) lumaN = lumaW;
if(!horzSpan) lumaS = lumaE;
float gradientN = abs(lumaN - lumaM);
float gradientS = abs(lumaS - lumaM);
lumaN = (lumaN + lumaM) * 0.5;
lumaS = (lumaS + lumaM) * 0.5;

bool pairN = gradientN >= gradientS;
if(!pairN) lumaN = lumaS;
if(!pairN) gradientN = gradientS;
if(!pairN) lengthSign *= -1.0;
float2 posN;
posN.x = pos.x + (horzSpan ? 0.0 : lengthSign * 0.5);
posN.y = pos.y + (horzSpan ? lengthSign * 0.5 : 0.0);


gradientN *= FXAA_SEARCH_THRESHOLD;

float2 posP = posN;
float2 offNP = horzSpan ? 
float2(rcpFrame.x, 0.0) :
float2(0.0f, rcpFrame.y); 
float lumaEndN;
float lumaEndP;	
bool doneN = false;
bool doneP = false;
posN += offNP * (-1.5);
posP += offNP * ( 1.5);
for(int i = 0; i < FXAA_SEARCH_STEPS; i++) 
{
 lumaEndN = dot(FxaaTexTop(SamplerColor, posN.xy).xyz, float3(0.299, 0.587, 0.114));
 lumaEndP = dot(FxaaTexTop(SamplerColor, posP.xy).xyz, float3(0.299, 0.587, 0.114));
 bool doneN2 = abs(lumaEndN - lumaN) >= gradientN;
 bool doneP2 = abs(lumaEndP - lumaN) >= gradientN;
 if(doneN2 && !doneN) posN += offNP;
 if(doneP2 && !doneP) posP -= offNP;
 if(doneN2 && doneP2) break;
 doneN = doneN2;
 doneP = doneP2;
 if(!doneN) posN -= offNP * 2.0;
 if(!doneP) posP += offNP * 2.0; 
}

float dstN = horzSpan ? pos.x - posN.x : pos.y - posN.y;
float dstP = horzSpan ? posP.x - pos.x : posP.y - pos.y;

bool directionN = dstN < dstP;
lumaEndN = directionN ? lumaEndN : lumaEndP;

if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0)) 
lengthSign = 0.0;

float spanLength = (dstP + dstN);
dstN = directionN ? dstN : dstP;
float subPixelOffset = 0.5 + (dstN * (-1.0/spanLength));
subPixelOffset += blendL * (1.0/8.0);
subPixelOffset *= lengthSign;
float3 rgbF = FxaaTexTop(SamplerColor, float2(pos.x + (horzSpan ? 0.0 : subPixelOffset), pos.y + (horzSpan ? subPixelOffset : 0.0))).xyz;

   #if (FXAA_LINEAR == 1)
lumaL *= lumaL;
   #endif
   float lumaF = dot(rgbF, float3(0.299, 0.587, 0.114)) + (1.0/(65536.0*256.0));
   float lumaB = lerp(lumaF, lumaL, blendL);
   float scale = min(4.0, lumaB/lumaF);
   rgbF *= scale;

   return float4(rgbF, lumaM); 
}

Fucking sweet!

btw Thanks [H] for doing an article on this, was the first I had heard of it.

Question tho, do we need a certain minimum driver version to support it for the OpenGL games where it seems they already support it (from the driver I would guess)?
 

wasteomind

Gawd
Joined
Aug 13, 2004
Messages
522
Is that GTA 4 image downsampled from a crazy high resolution? Looking at the buildings to the side, and the crane in the background, it is hard to believe it is that clean from just FXAA.
 

mejobloggs

Weaksauce
Joined
Oct 13, 2009
Messages
86
First I've heard of FXAA. Sounds awesome, thanks for the article

What would be more awesome is if they managed to implement it at driver level, but from the sounds of it it's technically impossible for the method they are using?
 

kn00tcn

n00b
Joined
Oct 10, 2008
Messages
44
Is that GTA 4 image downsampled from a crazy high resolution? Looking at the buildings to the side, and the crane in the background, it is hard to believe it is that clean from just FXAA.

look closer, the right half of the trunk below the mercedez logo is aliased & the diagonal pole holding the traffic light is also aliased & weird looking due to the depth blur cutting corners (not full rez, additional blur) so it can be fast enough ;)

also why would you think fxaa was doing the depth blur's work
 

wasteomind

Gawd
Joined
Aug 13, 2004
Messages
522
look closer, the right half of the trunk below the mercedez logo is aliased & the diagonal pole holding the traffic light is also aliased & weird looking due to the depth blur cutting corners (not full rez, additional blur) so it can be fast enough ;)

also why would you think fxaa was doing the depth blur's work

Well yeah, but GTA4 is normally a massive mess. I didn't think blur alone could make that much of a difference. I wanted to make sure it wasn't my eyes deceiving me. I figured there was a lot more going on in that pic then FXAA, and my first thought was a down sampled image since that tactic is used a lot for advertising. I looked at it on my laptop though and the screen on it isn't the best. Looking at it on my main pc screen, there is a lot more detail I can see.
 

CompuG##K

Gawd
Joined
Jul 9, 2008
Messages
593
Is that GTA 4 image downsampled from a crazy high resolution? Looking at the buildings to the side, and the crane in the background, it is hard to believe it is that clean from just FXAA.

The screenshot was taken at 1920x1200 via Fraps and then shrunk to 1680x1050 to make it fit to post on a forum without stretching the margins out of whack. So yes, I guess you can say it was downsampled a tiny bit. However, the majority of the smoothness in the picture is a result of FXAA. As far as the background blur goes, yes that's the DOF shader I'm using.


Another example of how FXAA works wonders in this game. Look at the car grille and how smooth it is. That was usually where aliasing was most visible without any sort of AA. Again, taken at 1920x1200 and reduced to 1680x1050, but even the full sized pic looked as smooth as this.
GTAIV2011-07-1622-52-21-86.jpg
 
Last edited:

hierovision

Limp Gawd
Joined
Oct 18, 2010
Messages
143
Considering the performance advantage, I think some aliasing on .000001% of screenshots is forgivable... No doubt it's a lot less noticeable while playing the game anyway.
 

teiresias

Limp Gawd
Joined
Sep 27, 2010
Messages
182
Anyone that uses PCSX2 for some PS2 emulation goodness may want to give the latest nightly builds a try too, because they've implement FXAA in it as an option now. Page-Up toggles it on and off.

If you can run anything at 4x internal resolution though I'm not sure you'll see much difference.
 

Roadhog

Limp Gawd
Joined
Oct 21, 2009
Messages
282
You should revisit MLAA performance with the new drivers.

http://support.amd.com/us/kbarticles/Pages/Catalyst118DriverPreview.aspx


AMD Catalyst Control Center / AMD Vision Engine Control Center 11.8 Driver Preview Features:
The following download provides the following features in addition to the AMD Catalyst Control Center / AMD Vision Engine Control Center 11.7 driver release

Enables AMD HD3D technology support on DisplayPort panels, such as Samsung 750 and 950 series 3D displays
Improves performance:
Up to 10% in Crysis 2 DirectX 11 version for both non-Anti-Aliasing, and application enabled Anti-Aliasing cases on the AMD Radeon&#8482; HD 6000 and AMD Radeon HD 5000 series of products
Up to 8% in Fear 3 DirectX 11 version with application enabled Anti-Aliasing on the AMD Radeon HD 6000 and AMD Radeon HD 5000 series of products
Up to 30% when AMD&#8217;s Morphological Anti-Aliasing (MLAA) is enabled through the Catalyst Control Center on AMD Radeon HD 6000 and AMD Radeon HD 5000 series of products
 

socK

Supreme [H]ardness
Joined
Jan 25, 2004
Messages
4,230
Anyone that uses PCSX2 for some PS2 emulation goodness may want to give the latest nightly builds a try too, because they've implement FXAA in it as an option now. Page-Up toggles it on and off.

If you can run anything at 4x internal resolution though I'm not sure you'll see much difference.

Kind of crazy that FXAA is catching on / spreading so insanely fast, wowee
 

BlueStorm

Gawd
Joined
Jan 2, 2009
Messages
738
The problem is it has to be implemented, that is additional development time which is expensive.

No, not really. It's a shader. It's pretty much drag and drop. If you want to tweak it, there are a couple values to tweak to tune it, but it's not required.

It's a post-process effect that works on the image that you've rendered, so doesn't need to be worked into the pipeline in some difficult or risky way.

It will be in the control panel in a while.
 

Evi1d33d

Weaksauce
Joined
Apr 21, 2010
Messages
114
Battlefield 3 Alpha has built in FXAA. I think the setting was set on low because it looks like 2X MSAA. I'm getting 45fps outdoors with FXAA and 30 with MLAA on the 6950. So I think FXAA is the way to go with its' open source-ness.
 

socK

Supreme [H]ardness
Joined
Jan 25, 2004
Messages
4,230
Battlefield 3 Alpha has built in FXAA. I think the setting was set on low because it looks like 2X MSAA. I'm getting 45fps outdoors with FXAA and 30 with MLAA on the 6950. So I think FXAA is the way to go with its' open source-ness.

There's already an open source GPU implementation of MLAA
 

socK

Supreme [H]ardness
Joined
Jan 25, 2004
Messages
4,230
So in other news, UDK has added support for both MLAA and FXAA, so it will probably be a feature in future Unreal Engine games.
 

Asacolips

Limp Gawd
Joined
Dec 4, 2008
Messages
272
I've messing with the FXAA injector hack on several games, and so far I love it. Decent quality aa at almost no performance loss, even on 5976x1080. Helped on Just Cause 2, at least!
 

MavericK

Zero Cool
Joined
Sep 2, 2004
Messages
31,362
I've messing with the FXAA injector hack on several games, and so far I love it. Decent quality aa at almost no performance loss, even on 5976x1080. Helped on Just Cause 2, at least!

Yeah, I've been using it in ArmA2:OA. Looks great and no real performance loss in a game where getting every drop of performance is key.
 

teiresias

Limp Gawd
Joined
Sep 27, 2010
Messages
182
Anyone tested this with The Witcher 2?

Oops, meant to post this in the forcing code topic!
 

PlayLoud

n00b
Joined
Jun 18, 2009
Messages
7
MLAA requires an AMD Radeon HD 5xxx or 6xxx series card to run. Does FXAA have the same limitation?

I'm really hoping SWTOR has an implementation of this!
 
Last edited:

HohnyF

Gawd
Joined
Nov 30, 2010
Messages
645
FXAA injector is the biggest thing in gaming in a loong long time

STALKER:CoP is a new game with it!
 

Evi1d33d

Weaksauce
Joined
Apr 21, 2010
Messages
114
I played Deus Ex 3 leak and the FXAA looked really good. Also on the new 11.8 beta driver for AMD:

Improves performance:
Up to 30% when AMD&#8217;s Morphological Anti-Aliasing (MLAA) is enabled through the Catalyst Control Center on AMD Radeon HD 6000 and AMD Radeon HD 5000 series of products

I guess FXAA forced AMD to step up on their game, everyone wins :D
 

archevilangel

[H]ard|Gawd
Joined
Jan 15, 2003
Messages
1,824
this is by far the most relevant thing I've read about on [H]ard in a while(not that the other articles aren't good, but relevant to my interests), thanks for the article
 

MaZa

2[H]4U
Joined
Sep 21, 2008
Messages
3,453
I have been playing around with FXAA in DNF and after that with FXAA hack. The things it does to the image is... curious. It is very obvious that the screen is blurred slightly, but not at the cost of too much detail. It gives the whole screen sort of mild 2xSAI filter look which I like.
 
Last edited:

flu!d

Gawd
Joined
Nov 7, 2007
Messages
562
Can anyone explain to me how I get the FXAA hack to work on JC2?

I've put the DX10 folder into the same folder as the .exe for the game yet when I hit the 'pause/break' button nothing happens?
 

socK

Supreme [H]ardness
Joined
Jan 25, 2004
Messages
4,230
It'd be nice if this was integrated in the Nvidia drivers by default.

i'd be nice to use it without using a hacky method like this, wouldn't be fun to get picked up by an anti cheat or something

MLAA requires an AMD Radeon HD 5xxx or 6xxx series card to run. Does FXAA have the same limitation?

I'm really hoping SWTOR has an implementation of this!

MLAA works on Nvidia, even AMD's version of it
 

IAMEVIL

Limp Gawd
Joined
May 8, 2011
Messages
142
I played Deus Ex 3 leak and the FXAA looked really good. Also on the new 11.8 beta driver for AMD:



I guess FXAA forced AMD to step up on their game, everyone wins :D

FXAA is very similar to MLAA in quality but sharper. The real difference is FXAA runs on regular DX9 pixel shader while MLAA runs on DX11 compute shader and performance hit is much worse. I guess it really goes to show how useless compute shader is. Ambient occlusion running in DX9 without compute shader already show very small performance hit in Crysis and Witcher 2. The only reason AMD keep pushing everything from AA to Ambient Occlusion to run on compute shader is to force users to upgrade their hardware.
 

shanepez

Limp Gawd
Joined
Aug 21, 2007
Messages
165
Turning on FXAA causes a big drop in FPS for me. I don't notice too much of a difference, so I'll keep it one level down.
 

ITSTHINKING

[H]ard|Gawd
Joined
Mar 1, 2006
Messages
1,260
I'm very sorry for bumping such an old write up that Mark and Brent did. I had to say though that this is a great article. I've been continuing to educate myself on AA modes since well...they can be somewhat confusing. Forever now I have just stuck to using MSAA (standard ass AA settings) on my last four or five GPU's dating back to my 8800 GTX even though they have all had evolving modes of AA. I was not a fan of FXAA because it has made some games look blurry, but I noticed for the first time today something new.

I still play Halo:CE 2 or 3 times a week and ever since it came out in 2004 on PC I had wished for proper AA support but it just didn't happen so I got used to it. Well I messed around and noticed that FXAA actually works! I also messed with mip map negative bias settings using nvidia inspector and it reduced the texture blur significantly in that specific game (although old and angular the game has rather nice textures for the time).

I'm still a little confused about things like CSAA (I'll keep researching) and if it's any good, I also noticed that SSAA is activated using the transparency AA driver settings... I still am partial to MSAA but I want to understand the driver settings better so I will know if a game that doesn't support MSAA may support other modes if it comes down to it. Again, I know this is me doing a necro on this thread but I never saw it in the past somehow and loved the read. So a belated thank you was in order.
I was actually trying to find out if I could use AA in java games like Minecraft and it lead me here>http://www.java-gaming.org/index.php?topic=24723.0 I was happy to be lead to [H] i just wish I read this a long time ago :D
 
Last edited:
Top