Advertisement Jump to content
Sign in to follow this  
Tree Penguin

The color buffer alpha channel...

This topic is 5198 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, is the alpha channel used when displaying opaque geometry? I mean if i set the alpha write off when drawing opaque triangles could i use the channel for other purposes (instead of a stencil buffer to be able to store more precise values for instance)?

Share this post

Link to post
Share on other sites
Of course you can use the alpha buffer for it. I for one love to use it because it has many advantages over the stencil buffer :
- many old graphics cards do support alpha buffers in hardware and not stencil buffers,
- you can use the blending stage for operating on the alpha buffer, useful for volumetric fog for instance (using subtractive blending),
- the alpha channel comes from color computation, thus allowing pixel shaders (or simply texture combiners) to generate alpha values, which means that you can sample eg a depth texture (useful for volumetric effects, again) or a color texture (useful for color keying for instance) for writing alpha components.

However, there are also disadvantages of using the alpha buffer instead of stencil :
- there are many operations you can't perform, like incrementing or decrementing the buffer, useful for stencil shadow volumes for instance,
- you can't use (or hardly use) alpha tricks in combination with translucent objects like glasses,
- the stencil buffer works tightly with the depth buffer, while doing this with alpha buffer needs pixel shader with depth texture (hard to setup and slow to render) AFAIK.

As for precision issues, it's somehow complex. Generally both alpha and stencil are stored into 8-bit. But the stencil buffer is a full integer buffer, which precision allows incrementing for instance, while the alpha buffer stores computations that often come from floating-point computations, allowing multiplication or division by two for instance. With that said, it's possible to use the alpha buffer with integer-like precision (with incrementing and-the-like), but it's very hard to handle it since it's not really designed for it.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!