View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# FXAA, why not use Depth

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

10 replies to this topic

Posted 25 July 2012 - 03:14 PM

I have not implemented FXAA yet due to not needing to. But I find it odd that they are trying to find edges by luminance instead of depth. Depth will give you an exact edge. From the Nvidia demo paper it shows a mostly non-contrasted image. I saw another nvidia youtube video showing real games using it but it doesn't show the edge detection that it picks up from the algorithm. I'm worried about high contrast textures getting blurred as a result of fxaa. So why not use depth (linearized before had or in pixel shader)? Is there a downside that I'm missing?

Edited by dpadam450, 25 July 2012 - 03:14 PM.

### #2Rattenhirn  Members

Posted 25 July 2012 - 03:37 PM

There are AA alorithms out there that use depth. But the big seller for FXAA is, that it only needs the backbuffer as input and does everything in one fairly simple pass. It's simple to integrate and fast to boot.

It can also smoothe edges with no depth information, for example reflections or refractions, as well as edges created by post processing.

In my experience, purely image based algorithms don't get signigicantly better than that.

### #3Ashaman73  Members

Posted 25 July 2012 - 11:23 PM

Depth will give you an exact edge

This is not always the case. I.e. I render lot of things which don't update the depth buffer (particles, effects, outlines etc.), in this case a depth depending AA would introduce some very ugly artifacts. A pure image based algorithm has the advantage of being usable for almost every rendering technique around, even if it has the disadvantage of smoothing out wanted contrasts. But to be honest, if you have textures with very high contrasts, you will have some other artifacts without AA applied to the texture itself, i.e. flickering when moving.

Ashaman

### #4MJP  Moderators

Posted 26 July 2012 - 01:13 AM

Depth alone also isn't enough to detect discontinuities in normals or other material parameters at triangle edges.

### #5dragon.R  Members

Posted 30 July 2012 - 02:31 AM

In my project I detect the edge using depth first, then use the stencil buffer to do FXAA only on the edge,just like in MLAA. Doing this increased the efficiency,and it also avoid FXAA to blur sharp pixels.

### #6B_old  Members

Posted 30 July 2012 - 02:40 AM

In my project I detect the edge using depth first, then use the stencil buffer to do FXAA only on the edge,just like in MLAA. Doing this increased the efficiency,and it also avoid FXAA to blur sharp pixels.

How do you get the edge information into the stencil buffer?

### #7dragon.R  Members

Posted 30 July 2012 - 02:49 AM

In my project I detect the edge using depth first, then use the stencil buffer to do FXAA only on the edge,just like in MLAA. Doing this increased the efficiency,and it also avoid FXAA to blur sharp pixels.

How do you get the edge information into the stencil buffer?

I just detect and render the edge in the first pass,open the stencil writting.So I can clip pixels using stencil test in the FXAA pass.

### #8Hodgman  Moderators

Posted 30 July 2012 - 09:52 PM

I'm worried about high contrast textures getting blurred as a result of fxaa.

Yes, high-contrast textures that produce aliasing will be anti-aliased. You'll have to tune/judge the algorithm on your scene to see if it's acceptable. It doesn't take long to integrate

So why not use depth?

Because that wasn't Mr Lottes' design goal -- making an luminosity-based edge filter was.
Also, geometrical-edge aliasing isn't the only cause of aliasing (as mentioned above), for me, the softening of shader-aliasing was very useful.

### #9B_old  Members

Posted 31 July 2012 - 03:19 AM

I just detect and render the edge in the first pass[...].

### #10dragon.R  Members

Posted 31 July 2012 - 09:32 PM

Its same to the first pass of MLAA,which was introduced in the <GPU PRO2>.Render a screen quad and sample the depth to find edge,discard other pixels.

### #11B_old  Members

Posted 01 August 2012 - 06:30 AM