Jump to content

  • Log In with Google      Sign In   
  • Create Account


Alpha Blending and Depth Testing, at the same time (OGL)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 September 1999 - 03:36 PM

I have got my engine working w/ Alpha blending, but when it draws, one poly might have the wrong ordering and will therefore draw at the back when its not meant to or something. I can fix this using glEnable(GL_DEPTH_TEST); but this then stops blending from working properly. The colours still blend w/ the background, but not w/ the other polys. Is there any way to get it to work. I have guessed that it is because I am drawing the semi-transparent poly first, so it blends w/ the background, and when the solid poly is drawn, it doesn't check to make sure the other was alpha 0.5. Would the only way around this be to sort the poly's and draw them in the right order myself?

Thanks

David


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 23 September 1999 - 12:48 PM

From what I understand, your polygons do have to be drawn in back to front order in order for blending/transparency to work. If you draw the slightly transparent polygon first, when you draw the one behind OpenGL has no idea that it needs to blend with it. If you have depth testing enabled, that second polygon won't even be drawn, as something in front of it already has been.

So you pretty much just have to sort the polygons before you draw them. No way around it.

Jonathan


#3 Facehat   Members   -  Reputation: 696

Like
Likes
Like

Posted 23 September 1999 - 03:36 PM

Also, if I remember correctly, besides sorting it you also want to do this:

glDepthMask(TRUE)
//Draw solid polygons

glDepthMask(FALSE)
//Draw transparent polygons

Basically your making the depth buffer read only when your drawing the translucent polygons.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS