Integrating FXAA

Revently I’ve integrated Timothy Lottes extreme powerful Anti-Alising filter Fast Approximate Anti-Aliasing into my ph.d.-project (might be introduced later on…).  It didn’t really take a long time as the filter source is documented quite well.

As I already have a class CPostProcessor that takes a base image and filters it using a generic vertex- and a custom fragment-shader I’ve created a class CPPFXAA that applies the FXAA filter.

1. Setup

Before integrating the FXAA shader you have to set it up, meaning going through the first part of the downloadable header-file and choose the defines to what you need/want.

2. Texture to RGBL

This step is not really necessary, but I somehow ended up integrating it anyway. Instead of an alpha value the alpha channel stores the luminace: (for me: color.a = dot(color.rgb, vec3(0.299, 0.587, 0.114));).

3. FXAA filter

Disable blending (if it was enabled) and apply the filter: render a screen-aligned quad with a fxaa as a fragment-shader. Set the input image as your “BaseImage” and set the correct viewport dimensions (“screenwidth” and “screenheight”).

4. done.

That’s it.

 

I hope it works as good for you as it does for me:)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>