Game Development Community

Adding FXAA to T3D - Live Blog!

by Tom Spilman · in Torque 3D Professional · 08/19/2011 (12:06 pm) · 40 replies

Hey guys.

So i decided today i was gonna spend one hour and "live blog" my experience merging Timothy Lottes' FXAA into Torque 3D 1.2 replacing the MLAA implementation.

Ready, Set, Go!


About the author

Tom is a programmer and co-owner of Sickhead Games, LLC.

Page «Previous 1 2
#1
08/19/2011 (12:10 pm)
I'm dragging ass today... 5 hours of sleep last night.

I've been testing TortoiseSVN 1.7 which is fantastic by the way... but that means i'm stuck doing a repo update right now.

Lame.
#2
08/19/2011 (12:18 pm)
While i wait for that i'm grabbing the latest version of FXAA... 3.11... they have been updating it every few weeks.

He distributes it as a single Fxaa3_11.h file which is really nice and the license is totally open for commercial use. Three cheers for Tim!

To include it without modifiying it i'm gonna #include it from an HLSL file. This should allow for future updates being almost drag and drop!
#3
08/19/2011 (12:25 pm)
Starting to hook his code to the T3D shader... you just call his main 'FxaaPixelShader' function and pass all the correct parameters... and there are alot of them.

I'm using the FXAA_GREEN_AS_LUMA toggle for now as i want to get a first result quick.

A little worried about performance compiling the shader... its huge at 86K. If it becomes a problem i can trim out the #ifdefs for console and other platforms that are not importaint to most T3D 1.2 users.


#4
08/19/2011 (12:37 pm)
The SVN working copy update is still going... lame... but i can still write shaders and get ready.

Lot of parameters to this thing... almost have those worked out. His docs inline to the shader are very very good!


#5
08/19/2011 (12:44 pm)
Ok i think i have the HLSL hooked up right... its actually super simple in the end. I'm using the stock postFxV.hlsl to process the triangle and get UVs.

Now off to hooking up the PostEffect TorqueScript files to call this thing.

SVN is *still* updating my working copy! :(

#6
08/19/2011 (12:50 pm)
I don't have a good text editor on this box... so been using notepad to edit the shader. ;)

Copied the MLAA PostEffect to start with and begain modifiying it... seems like a good point to start. It's Torsion Time!

SVN working copy update finished... now to update from the repo. The T3D 1.2 team has been doing a ton of work... i hope it doesn't take too long.
#7
08/19/2011 (12:56 pm)
Ok... that was simple... got my fxaa.cs post effect setup. I can already tell this is gonna be so much faster than MLAA... its a single pass effect and has so few inputs.

Now i need to go capture some MLAA screenshots and metrics in the Deathball level.

First... another Coke!
#8
08/19/2011 (1:00 pm)
SVN update finished... i can add my files before i forget about them.

Now to build the latest EXEs... don't want to be caught with a broken build.


#9
08/19/2011 (1:08 pm)
Hitting the one hour mark... for not being well setup on my laptop, not having SVN up to data, and doing a full rebuild of T3D... things are going pretty quick.

The block might come if the shader doesn't work... thats yet to be seen. :)

T3D is still building... on my i5 laptop it takes....
#10
08/19/2011 (1:10 pm)
... build finished... took 3 minutes and 55 seconds. Not bad for this rather large older C++ code base.

Now off to testing MLAA. I'm running it via Torsion so i can capture any script failures easily if i made one.
#11
08/19/2011 (2:01 pm)
Ok... captured screens after some technical difficulty. FXAA is not only 2ms to 4ms faster than MLAA on and its significatly better quality.

I have to hit a meeting, but i'll come back and post shots in like 30 minutes.
#12
08/19/2011 (3:02 pm)
Ok... i uploaded the raw images to our Flickr account.

www.flickr.com/photos/sickheadgames/tags/FXAA/

Gonna get one of the GG artists to cut them up for me to get good comparisions.


#13
08/19/2011 (5:21 pm)
I didn't feel like waiting.. ;)
this is a watered down thumbnail to save loadtime and BW..so click the image to see the 1280x720

torque.abigholeintheweb.com/public_system/useruploads/noaa_mlaa_fxaa_th.jpg

..good stuff!
#14
08/19/2011 (7:03 pm)
Thanks EB... this is the one we made here.


farm7.static.flickr.com/6086/6060886664_e6c3f6c645_z.jpg

(click thru for the full size)

As you can see the quality is significantly better than MLAA... and it is faster to boot. Remember this is a i5 laptop... running the high quality deferred... don't fret over the overall time. Its the comparision between the times that will matter... and generally i've seen 2 mspf (milliseconds per-frame) to 4 mspf.

This could be tweaked to have even higher quality if we did a pass gathering the luma values into the alpha channel of the color buffer... i decided to use the FXAA_GREEN_AS_LUMA option for now. If you wanted to change that optimally you would just alter the HDR code to store luma into alpha as part of its final pass.

So i've got this commited and it will be shipping with T3D 1.2 soon. Thanks for reading!
#15
08/19/2011 (7:43 pm)
Nice - sweet deal if you ask me. Faster and better is a rare thing... lol.
#16
08/19/2011 (7:57 pm)
Great stuff, Tom. Should be a nifty improvement to T3D.
#17
08/20/2011 (1:02 am)
looks great Tom.
#18
08/20/2011 (2:46 am)
wow, that is really a HUGE improvement!!!
#19
08/20/2011 (5:36 am)
I think the MLAA looks much better, is there any chance that this can be optional, or made easy to rollback once its released?
#20
08/20/2011 (5:50 am)
I definitely prefer your FXAA, but there's a noticeable loss of sharpness on textures not on edges, like the rock arch. I still think the trade-off is worth the change, but could anything be done to the algorithm to keep that bit of sharpness?
Page «Previous 1 2