Jump to content
  • Advertisement
Sign in to follow this  
pamaro

OpenGL Problem with transparencies

This topic is 4957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I've ran into something weird while checking out an OpenGL program... not sure what's causing it or if it can be fixed. Anyway, here's the problem. In the program, there's a model which is placed in the middle of two "walls". One of the walls is solid, while we can control the transparency of the other wall. We can also controlo the transparency of the model. When placing the second wall as semi transparent and the model as transparent, the expected result would be seeing only the two walls. However, I can see the outline of the model. Anyone knows why this happens? Here's a screenshot: http://img37.exs.cx/img37/5830/pic248.jpg

Share this post


Link to post
Share on other sites
Advertisement
Your problem is Z-Buffering.

Drawing multiple translucent objects in a scene is always tricky... even more so if these objects are concave.

Basically, when you draw your model you have z buffering enabled. Even if it is transparent it still writes and checks against every pixel of the z-buffer.

So if you drew the model before the wall, even though it is clear, it is still setting z-depth at those pixels. The result is that when you draw the back wall with depth testing, the shillouete of the model will not be drawn.

The simplest fix would be to draw the opaque wall first. Then call DepthMask(GL_FALSE);. Then draw the model and the wall in either order.

This tells opengl to do depth compares, but not write anything new to the z-buffer. Which means that you can draw new things behind transparent polygons.

Depending on the blend operation you use, things may not look correct. Try changing the glBlendFunc or do somethign like: draw all transparent objects from farthest to nearest so it is consistant.

[Edited by - nihilisticod on November 28, 2004 4:19:29 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!