Solved

Alpha blending and polygon antialiasing ?

Posted on 2006-10-19
7
1,264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating graphics and animations for Android 4 795
Questions about virtual reality solution 8 330
RTS server listeners separate Threads, or one Listener? 20 180
Fibonacci challenge 11 141
What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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