Problems with antialiasing

Started by
10 comments, last by Enrico 17 years, 1 month ago
I'm having some problems with antialiasing in my application... I've added the code: glEnable(GL_POLYGON_SMOOTH); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); But my polygons are still serrated, and I can't achieve this effect! Can you help me? Thanks, and sorry for my English!
Advertisement
IIRC you also need to enable blending (glEnable(GL_BLEND)) and set the blending function (glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)).
This is no real Antialiasing filter. You might want to look up for GL_ARB_multisample, which allows you to enable a real multisampling filter for your application.

@OrangyTang: What has this to do with Blending??
--
Either if I don't use alpha blending?
Ok Enrico!
But my application loads some complex objects from files...
Don't it will be very slowly to apply a multisample algorithm to a huge quantity of polygons?
The polygon based antialiasing will smooth the edges using alpha blending (so it'll almost certainly need to be switched on), but you'll need to sort your polys from back to front for it to work correctly.

MSAA will work for most general cases, but may not be available on all GPUs especially if you use a floating-point based format. But multisampling should have a more consistant GPU hit.
Here is an example of what I'm getting:
Example
As you can see the image have a lot of "jaggies"!
Quote:Original post by FiPoO
Ok Enrico!
But my application loads some complex objects from files...
Don't it will be very slowly to apply a multisample algorithm to a huge quantity of polygons?

I don't know how slow it will become, but you get nothing for free. Either smooth polygon borders with a speed decrease or jaggy borders at full speed...

--
Quote:Original post by FiPoO
Ok Enrico!
But my application loads some complex objects from files...
Don't it will be very slowly to apply a multisample algorithm to a huge quantity of polygons?

Yes, it has the potential to slow your application down quite a bit. All of the sampling is done in hardware though, which is very fast. As ever in real-time graphics, it's a trade-off between image quality and rendering speed.

There are several different levels of anti-aliasing, usually ranging from 2 samples to 16. Depending on the complexity of your scene and the spec of your graphics card, I guess you should be able to use 2x-4x sampling without a massive frame-rate hit. Could be wrong, though.

Quote:Original post by Enrico
@OrangyTang: What has this to do with Blending??

Line and polygon smoothing adds extra pixels with decreasing alpha values around lines and polygons. If blending isn't enabled, the alpha values aren't used, and the extra pixels appear solid.
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]
Another thing, if I set my hardware to compute antialiasing (2X is enough) the problem goes away...
But I can't say to all final user to do this after installing the application.
Isn't in opengl any solution to just decrease this "jaggies"?

Thanks for the replies!

This topic is closed to new replies.

Advertisement