PDA

View Full Version : AntiAliasing



devdept
04-01-2010, 12:53 PM
Hi All,

Is it possible that anti-aliasing is active on an OpenGL viewport even if you didn't request it? For example forcing it in the Windows graphics adapter settings?

Is there a way to create a viewport *without* anti-aliasing even in this scenario?

Thanks,

Alberto

Alfonse Reinheart
04-01-2010, 12:59 PM
Is it possible that anti-aliasing is active on an OpenGL viewport even if you didn't request it? For example forcing it in the Windows graphics adapter settings?

Yes.


Is there a way to create a viewport *without* anti-aliasing even in this scenario?

No. Well, it depends.

If the driver wants a multisampled framebuffer, you will get a multisampled framebuffer. There's nothing you can do about that. However, FBOs are another matter entirely.

If you want to force no multisampling, your first step is to detect if the driver has given you a multisampled default framebuffer. I believe glGetIntegerv(GL_SAMPLES) will be 0 if not multisampled.

If it is multisampled, you can do one of two things. You can display a pop-up that politely asks the user to stop forcing multisampled display. Or you can do it behind their back.

Create color and depth/stencil renderbuffers the size of the window. These should not be multisampled, and these are what you will render to. At the end of the frame, before swapping buffers, do a blit from these renderbuffers to the multisample default buffer. Blits from singlesample to multisample will cause each pixel to be copied into the multiple samples. So the eventual multisample reduction on swapping will result in the same thing it started out with.

devdept
04-01-2010, 01:16 PM
Thanks Alfonse for the detailed answer. I thought that the workaround was easier than that.

I need this not anti-aliased viewport to perform selection using the object ID encoded in the object color, then I read the pickBox bitmap and look for object id in every pixel color. The problem is that if the antialiasing is active I get some pixels with values not in the range 0-maxObjectCount and the procedure fails.

Do you know any other workaround for this issue?


Thanks so much again,

Alberto

MaxH
04-01-2010, 04:38 PM
I need this not anti-aliased viewport ...
Do you know any other workaround for this issue?

I also need to generate anti-aliased OpenGL scenes in cases where I render a scene, read the image back into an array (with glReadPixels) then do some statistical analysis on the image. This 'analysis' is usually something simple like counting how many pixels of a certain color are in the image. I must have no anti-aliasing or dithering. I also turn off lighting and apply simple coloring to objects. That way I know EXACTLY what RGB values to expect on each pixel.

Your video card has settings that you can change to make sure AA and dithering are off. When porting one of my apps to a coworker's laptop a few years ago, we found that his video card would dither at the screen resolution needed by my sim. Our workaround was to lower his screen rez just enough to get the pixel depth we needed to avoid dithering. Part of my sim was off the screen, but enough of it was visible to accomplish the image processing. (This is probably where off-screen rendering might come in handy :)

On a Windows computer, go to:
1) Start
2) Control Panel
3) Display
4) Settings
5) Advanced
6) Graphics card tab which should allow you to
turn anti-aliasing off

beginnertom
04-01-2010, 10:39 PM
I need this not anti-aliased viewport ...
Do you know any other workaround for this issue?

I also need to generate anti-aliased OpenGL scenes in cases where I render a scene, read the image back into an array (with glReadPixels) then do some statistical analysis on the image. This 'analysis' is usually something simple like counting how many pixels of a certain color are in the image. I must have no anti-aliasing or dithering. I also turn off lighting and apply simple coloring to objects. That way I know EXACTLY what RGB values to expect on each pixel.

i had draw a cube.
it looks like this.
http://hellotom3389.blog.com/files/2010/04/boxb21.jpg
and i rotated it
like this
http://hellotom3389.blog.com/files/2010/04/boxb1.jpg

devdept
04-01-2010, 11:28 PM
Hi Alfonse,

What about discarding pixels with alpha different from one? Will it help to get only right object IDs even if the AntiAliasing is forced via Windows control panel settings?

Thanks,

Alberto

Alfonse Reinheart
04-02-2010, 12:21 AM
What about discarding pixels with alpha different from one? Will it help to get only right object IDs even if the AntiAliasing is forced via Windows control panel settings?

Alpha has nothing to do with multisample antialiasing.

devdept
04-02-2010, 02:06 AM
I see, thanks.

Alberto