Solved

Alpha blending and polygon antialiasing ?

Posted on 2006-10-19
7
1,243 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 1

Author Comment

by:Alexander
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with points refunded (200)

Computer101
EE Admin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now