Sign in to follow this  
FiPoO

Problems with antialiasing

Recommended Posts

FiPoO    122
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!

Share this post


Link to post
Share on other sites
OrangyTang    1298
IIRC you also need to enable blending (glEnable(GL_BLEND)) and set the blending function (glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)).

Share this post


Link to post
Share on other sites
Enrico    316
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??

Share this post


Link to post
Share on other sites
FiPoO    122
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Enrico    316
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...

Share this post


Link to post
Share on other sites
iNsAn1tY    476
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.

Share this post


Link to post
Share on other sites
FiPoO    122
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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
You should use opengl extensions to activate multisample.

And in windows you have to create 2 windows context. I opened a thread about this some months ago. Search it!

It is a bit horrible to create a window and after that, another windows with 2x or 4x multisampling.

By the way, I have tested 2x and 4x and 4x is very fine, and my application is very fast.


I hope this help you.

Bye

Share this post


Link to post
Share on other sites
Enrico    316
Quote:
Original post by FiPoO
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!

What you have done is forcing the driver to apply antialiasing. As I said before, implement GL_ARB_multisample, which gives your application control over antialiasing settings (which is what most modern applications/games do). Creating a window with a multisampled framebuffer depends on your windowing system. Using SDL it is only three more lines to your init code and you get multisampling :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this