# Double, Triple, and More Partially Transparent Masks

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

## Recommended Posts

Hi, So, this comes about because I'm trying to make a rocket launch in a flight simulator, and I want to have spherical clouds of smoke. My solution is to use 2D textures that always face the camera. I made the necessary texture, and have them so that they will always face the camera, etc. By nature, smoke is not opaque, and the smoke puff will be thickest (most opaque) at the center of the cloud. So, I made the necessary alpha channel to go along with that too. The problem arises when I try to do the masking. Unfortunately, while this masks beautifully over other objects, it does not mask over similar clouds. See the screenshot: The German Triplane has just launched a rocket (rocket is on the upper right). As you can see, the clouds mask over the landscape, but not over each other. It should be noted that I can get the masking to work by using colorkeys, but, of course, clouds aren't either completely transparent or completely opaque. I'm working in Python and am using Pygame for the image loading. Here's the colorkey version:
#This works, but doesn't do partial masks.  Only binary-
#either completely opaque or completely transparent.
CloudFile = os.path.join('Data','Cloud.png')
CloudSurface.set_colorkey((255,255,255), 0)
ImageData = pygame.image.tostring(CloudSurface, "RGBA", 1)

How do I change this so that I can get partially transparent masks over each other? G [Edited by - Geometrian on November 2, 2007 1:53:36 AM]

##### Share on other sites
If I'm understanding the problem correctly, then your clouds aren't blending with each other and making it darker where they overlap? If so:

This is a common problem with transparent textures and the depth buffer. When you draw a polygon, even if it is 100% transparent, then all pixels that correspond to that polygon are written into the depth buffer if they are closer than what's already there. This unfortunately means that if you're going to use the depth buffer, then transparent textures will not overlap -- you'll only see the closest one to you.

What you have to do is first draw all of your 100% opaque polygons normally. Then you have to disable your depth buffer write (yes, you keep your depth buffer reads intact - you do this by calling glDepthMask(GL_FALSE)). Once that's done, you draw all of your transparent polygons.