Solved

Alpha blending and polygon antialiasing ?

Posted on 2006-10-19
7
1,255 Views
Last Modified: 2013-12-06
Hi,
 I'm trying to display polygons with antialiasing over a not-black background. At first, i've used
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
And then everything goes well over a black background... But when i've anything with another color in background, it modifies the color of my polygon.
Then i've tried to use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); but then, i see the tesselated edges of my polygon.

So i'm looking for a way to get polygon edges antialiasing without having those nasty tesselated lines displayed... but keeping my original polygon's color, is it possible ? if yes, how ?

If you want, i can send you images by e-mail...

Thank you in advance,
Alexander
0
Comment
Question by:Alexander
  • 3
  • 2
7 Comments
 
LVL 22

Expert Comment

by:NovaDenizen
ID: 17797073
http://glprogramming.com/red/chapter06.html

From the section "Antialiasing Polygons":
"In theory, you can antialias polygons in either RGBA or color-index mode. However, object intersections affect polygon antialiasing more than they affect point or line antialiasing, so rendering order and blending accuracy become more critical. In fact, they're so critical that if you're antialiasing more than one polygon, you need to order the polygons from front to back and then use glBlendFunc() with GL_SRC_ALPHA_SATURATE for the source factor and GL_ONE for the destination factor. Thus, antialiasing polygons in color-index mode normally isn't practical."

To do proper antialiased polygons, you have to use GL_SRC_ALPHA_SATURATE,GL_ONE and draw your polygons in front-to-back order.  You can't really use the z-buffer here, and you have to clear the alpha channel to zero before you start drawing, and draw your background in last of all.  
0
 
LVL 1

Author Comment

by:Alexander
ID: 17797449
Sorry i've the OpenGL programming guide (fifth edition) too, and i've already read that. The problem is that i'm rendering a 2D scene and then to manage objects superposition i need to draw them from background to top.

On another hand, since i've asked this question, i've learned that using GL_MULTISAMPLING could be the solution. I'm not using glut but windows SDK so i'm looking for now on how to get a multisampled OpenGL context. Maybe in PIXELFORMATDESCRIPTOR ?

Thankyou anyway,
Alexander
0
 
LVL 22

Expert Comment

by:NovaDenizen
ID: 17797531
I'm not 100% sure on the low-level details, but I think you can only get polygon antialiasing that looks right if you follow the front-to-back requirement and use the (GL_SRC_ALPHA_SATURATE, GL_ONE) blend mode.  It intuitively seems like other ways of doing it would work, but unfortunately things like the triangle seams show up for polygons more complex than triangles.

I haven't used GL_MULTISAMPLING yet, so I can't really comment on it.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:Alexander
ID: 17797656
i think i've found how to activate multisampling on windows SDK, i'll try it and thell you if it work, take a look at http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46
It is a gold mine ! :D

Thank you anyway !
Alexander
0
 
LVL 1

Author Comment

by:Alexander
ID: 17809598
Ok, it wasn't easy but once it is done and activated there is no more tesselation anti-aliasing alpha-blending problems when using FAAS and multisampling ! now my scene looks pretty well !

Thank you anyway for trying,
Alexander

This question is closed for me : considering that i've found the answer by myself, nobody gets any points.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18320916
PAQed with points refunded (200)

Computer101
EE Admin
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Software to create cartoons/animations 2 351
How do I lock down a trademark? 11 77
FPS using mouse to move rather than keys in Unity 3d 2 217
Compile GLUT with Visual Studio 2015 1 143
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question