simple 2xFSAA using standard OpenGL

BlitzMax Forums/MiniB3D Module/simple 2xFSAA using standard OpenGL

AdamRedwoods(Posted 2011) [#1]
This code shows how to do a simple FSAA using miniB3d and OpenGL1.2. This means the output render is rendered 4 times at 2x scale, then resampled to fit on the screen. During the resampling, we use OpenGL's texture parameter GL_LINEAR to soften edges.

The trick is to play with the camera's frustum and render this to 4 textures. Seems to work fine without a huge performance hit.

WHY DO THIS?
I have tried to get multisampling AA to work on say, IntelG41 (*gag*), but yet it doesn't support it, even though it says it is Opengl 2.1 compliant. Other legacy cards or even so-called modern cards may not support multisample AA, so I have implemented a simple version myself.

I have tried using miniB3D's AA using the accum buffer, but this is terribly slow and reduces the frame rate drastically. My version uses more memory but is much faster.

FURTHER STEPS?
This will need a lot of testing, but I wonder if this can be incorporated into miniB3D for all to use. If not, that's fine too.

EVEN FURTHER?
I have begun experimenting with arb fragment programs which could apply a soft filter to make the jaggies go away even more. arb fragment programs seem to be compatible with many graphic cards in the market today, including some legacy ones.


THE CODE:

In order to make this possible in miniB3D, a simple painless hack is needed in TGLOBAL.BMX:


Then you can use the following code to see if FSAA works for you.
Use the arrow keys to rotate the primitives and hold SPACE to activate the FSAA.

example:


Last edited 2011

Last edited 2011


ima747(Posted 2011) [#2]
Haven't had a chance to play with this myself but sounds fantastic, would love to have multiple options available.


Kryzon(Posted 2011) [#3]
I haven't tested this, but it seems nice - I'm very interested in the the quad-rendering and projection bits, it's sample code on what you don't find in a plain form around the web. I dislike manual super-sampling, but if it does not pose such a performance loss then it's a great alternative to an incompatible card. Thanks a lot for sharing your work.

For those that don't know, there is a hardware way to do multisampling AA (by 'hardware' I mean real-fast, but as Adam mentioned not all old\lower-grade cards will have it): http://blitzbasic.com/Community/posts.php?topic=64265#1022476 - it even has my unresponded question. Woohey (if anyone still has the answer for that, I'd love to hear).


AdamRedwoods(Posted 2011) [#4]
Also I want to note that holding down the 'space' key on the example above may sometimes lower the frame rate. setting the 'else' statement to just 'true' sped the example up for me (on an Intel G41 integrated board). I'll test this on other cards when I get a chance.