The color buffer alpha channel...
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)?
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.
- 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement