PDA

View Full Version : Antialiasing and Transperancy



Pan007
08-29-2011, 04:13 AM
Hello,

I wanted to make antialiasing for some of my scenes..I am actually using GL_MAP2_VERTEX_3, please see the code below.
glPushMatrix( );

/* Translate to the Position */
glTranslated( X , Y , Z );

/* Rotation of the position */
glRotatef( Angle , X_R , Y_R , Z_R );

/* Translucency */
glEnable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

glEnable ( GL_LINE_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
/* Color of polygon inside */
glColor4f( fR , fG , fB , Alpha );

/* draw the surface */
glEnable(GL_DEPTH_TEST);
glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 5 , 0, 1, 15 , 2 , ArrayofPoints);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_AUTO_NORMAL);
glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);
glEvalMesh2(GL_LINE, 0, 20, 0, 20 );
glEvalMesh2(GL_FILL, 0, 20, 0, 20 );
glDisable(GL_DEPTH_TEST );
glDisable(GL_MAP2_VERTEX_3);
glDisable(GL_AUTO_NORMAL);
// Disable Alpha Channel
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH);
glPopMatrix();

When i use line smooth and pass GL_Line to EvalMesh i.e
Gl::glEvalMesh2(Gl::GL_LINE, 0, 20, 0, 20 );
then i am able to achieve antialiasing but I also need transperency during few cases, which is not working when I antialias. But without antialiasing this transperency is working.

Can anyone help me out in this regard?? I need to preserve this transperency affect even if i use Antialiasing tecniques.

Please also let me know if there is any other way to do achive both antialiasing and transperency in this scenario.

dorbie
08-29-2011, 09:55 AM
You could try sorting so that you draw any transparent effects after the terrain and smooth lines.

There are better ways to achieve anti-aliasing on modern hardware by chosing a visual with multisample support and enabling multisample buffer for the number of samples you want.

This is inevitably bounded by the number of samples available in the visual and there is a performance degredation but it is always efficiently implemented on modern hardware.

The setup for the display can be convoluted as you have to check for support.

http://www.opengl.org/registry/specs/ARB/multisample.txt

You can also override this via your driver which will be easier. Users can use their driver settings to override your application choices here anyway and often do.

Pan007
08-30-2011, 12:38 AM
I am using a standard Opengl 2.0 in windows environment..I think for multisampling support we require an advanced Hardware like nvidia Graphics card (GPU's may be) to achieve this particular Antialiasing. But unfortunately I dont have this H/w support.
That's the reason why I am using this simple Anti-Alasing techniques to achieve the smoothness.

Please give me some alternate solution for current implementation or let me know if there is any better way to achieve Transperancy in this cases.

Alfonse Reinheart
08-30-2011, 02:10 AM
Well, you're not getting an OpenGL 2.0 implementation without some kind of hardware support. If it supports WGL_ARB_multisample (and pretty much everything since the GeForce 2 does), then you can use it.

aqnuep
08-30-2011, 02:16 AM
Actually ARB_multisample is in core since OpenGL 1.3 and every modern graphics card should be able to handle it (even Intel cards).

Pan007
08-30-2011, 04:07 AM
Thanks for the response!

I dont have knowledge on how Multisampling would be used. I mean how to enable and how to use the API's for achieving Anti-Aliasing.

I would like to have a look at some code examples of how it can be done..
I will check for few examples in the web. If u have any sample code examples please share.

Thanks!