PDA

View Full Version : ANti - Ailiasing



Me6
08-04-2004, 05:22 PM
Can somone show me some code that does antialiasing in an open GL Program? Or a link to a tutorial or page about it? Thanks

Cheps
08-04-2004, 09:40 PM
If you want regular antialiasing, you need something like this:



glEnable(GL_BLEND); //antialiasing uses blending
glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); //this is to change the way blending is applied, see docs for more details

glEnable(GL_POLYGON_SMOOTH); //enable antialiasing for polygons
glEnable(GL_LINE_SMOOTH); //enable antialiasing for lines
glEnable(GL_POINT_SMOOTH); //enable antialiasing for points
If you want to use multisampling(ie antialiasing 2x, 4x, etc) it's a bit different.

Me6
08-05-2004, 05:44 AM
Thank you for your reply, What is the difference between anti-aliasing and multisampling? Thanks

Me6
08-05-2004, 06:07 AM
ok a couple of questions:

1. I put the code into my InitGL void and when I run the program my objects dissappeared, but when I commented out the line :


glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ONE); //this is to change the way blending is applied, see docs for more detailsthey re appeared, but the objects didn't look anymore smooth that before. What is wrong?

2. Did I put the code in the right place?

3. If I didn't, Were does it go?

Thank you....

dorbie
08-05-2004, 06:53 AM
Multisampling is a method of antialiasing that works well with OpenGL's zbuffered rendering because it generates multiple samples for each pixel that contribute to the final pixel's color.

The linesmooth & polysmooth methods generate alpha fragments at the edges of primitives so that individual lines or triangles can be antialiased, however they do nothing to ensure that the overall scene will look acceptable and correct especially when zbuffered. It probably won't unless you disable depth testing and use a polygon sorting algorithm in conjunction with the saturate alpha blend function and that can be too computationally expensive to implement and defeat efficient rendering.

Multisample AA can cost a lot of fill performance (depending in the implementation) and use additional framebuffer memory with quality limited in proportion to the memory and performance hit. Blended antialiasing while high quality does not play nicely with zbuffered rendering.

Read this for info on an easier method of antialiasing.
http://developer.nvidia.com/object/gdc_ogl_multisample.html

Me6
08-05-2004, 07:59 AM
Thank you very much, i will try that.