[LWJGL] Anti-Aliasing? How does it work

I wanted to try to add some sort of Anti-Aliasing to my current Java project, but I haven’t a clue where to start. My question is, in LWJGL is AA a shader? Or is it a toggle-able option?

LMGTFY :wink:

Not only does that not answer the question I asked in my topic, but I find that the use of “let me google that for you” is quite condescending. Obviously I googled the topic before posting; if I found google helpful I wouldn’t have created a post in the first place.

Sorry, I apoligize for that.

But shouldn’t you be able to find that out through google anyway?
I mean, I just googled ‘is anti aliasing a shader,’ and it came up with ‘FXAA - shader based anti-aliasing.’ So from that, you can tell that AA shaders exist.

But, yet another result ‘Antialiasing’ shows that it could also be a list of settings enabled in OGL.

So from this googling, we can gather that AA is a look that you want to achieve. It can be through Shaders, or plain OGL.

NEHE Anti-aliasing Apparently its been around for a while! You can perform AA with both pipelines, but I quite honestly wouldn’t know where to point you to start! I guess you could use NEHE, but I wouldn’t recommend it.

It depends on what you want to apply it on.

  • For geometry primitive edges, multisampling is the standard. Useless for most 2D.
  • For textures, it’s linear filtering and mipmaps.
  • For 2D lines and points without depth testing, you can use the GL_LINE_SMOOTH and GL_POINT_SMOOTH enables.

FXAA is simply a hack for making the image suffer less from jagged edges by blurring them in a somewhat smart way. It doesn’t help with pixel-sized problems since there’s not enough sub-pixel information. Multisampling helps with this by storing multiple values per pixel and then averaging these together at the end for the final pixel color. However, it only applies this to triangle/line/point edges, so if you have a shader or an unfiltered texture applied to your geometry it won’t help at all. For textures, proper filtering is required, especially when downsampling textures, which is what mipmapping solves.

If you are looking for anti aliased lines, see here:

For general primitives, theagentd pretty much summed it up.

An easy alternative for static geometry is to use Java2D as your polygon rasterizer – draw to buffered image and copy to GL texture. Obviously only possible on desktop.

Something like this?


if (settings.useAA()) {
    Display.create(new PixelFormat(32, 0, 24, 0, 4));
} else {
    Display.create(new PixelFormat(32, 0, 24, 0, 0));
}

That’s how it looks like in my game :slight_smile:

Mike

On some (weird) graphic setups this can throw a exception.
When it does, make sure you call display without aa.