FXAA, why not use Depth

This topic is 1995 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites
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.

Share on other sites
Depth will give you an exact edge
[/quote]
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 [i]wanted[/i] 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.

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

Share on other sites
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.

Share on other sites
[quote name='dragon.R' timestamp='1343637063' post='4964422']
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.
[/quote]
How do you get the edge information into the stencil buffer?

Share on other sites
[quote name='B_old' timestamp='1343637635' post='4964424']
[quote name='dragon.R' timestamp='1343637063' post='4964422']
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.
[/quote]
How do you get the edge information into the stencil buffer?
[/quote]

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.

Share on other sites
[quote name='dpadam450' timestamp='1343250854' post='4963067']I'm worried about high contrast textures getting blurred as a result of fxaa.[/quote]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
[quote]So why not use depth?[/quote]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.

Share on other sites
[quote name='dragon.R' timestamp='1343638173' post='4964427']
I just detect and render the edge in the first pass[...].
[/quote]

Share on other sites
[quote name='B_old' timestamp='1343726342' post='4964780']
[/quote]

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.

Share on other sites
[quote name='dragon.R' timestamp='1343791970' post='4965072']
[quote name='B_old' timestamp='1343726342' post='4964780']