When 3D acceleration is done, each pixel has have a colour value. The colou value is the result of the
rendering pipeline. But to get that colour, a lot of other information had to be know about that pixel.
Color Depth
Colour depth is the amount of colours that the pixel can be. The most common are 16-bit and 32-bit.
But why only 3D accelerated only played in 16-bit and 32-bit? What happened to being able to play in
8-bit 256 colour mode, or 24-bit colour? And why can games run in 32-bit but note 24-bit, when both
have the same number of colours?
16-bit
16-bit colour has been the most used depth for a while now, but newer video cards are making the
progression to 32-bits because of increased RAM bandwidth and frequencies. 16-bit colour is capable
of over 65 thousand different colours. There are 3 primary colours, but only 16-bits, so there is an
improper bit allocation. When running in 2D, the extra bit is given to the green value, and can be
expressed as 5-6-5. This means that there are 32 different shades of both red and blue, but green is
capable of 64 different shades. This is a sloppy way to do things.
Games use the extra bit as an alpha value. This is represented as 5-5-5-1. This is good for
sprites or simple transparency, but it is severely limited. A pixel can be opace, or it can be
translucent. There is no in between. So some games choose to do things a bit differently. They re-
divide the bits more fairly. They give 4 bits to each value; red, green, blue and alpha. This is written as
4-4-4-4, and is much better because it allows for proper transparencies. This limits 3D accelerated
games to only 4096 colours, which 16 levels of alpha. You can now appreciate why game
programmers want to use 32-bit colour depths to make their games look better.
32-bit VS 24-bit
The reasoning behind colour depths is in the bit arrangement. Since computer RAM stores information
in 64-bit chunks, 24-bit colour can not be used without wasted bandwidth. If 2 pixels were to be
stored in memory, there would be 16-bits that were left unused. If 3 24-bit pixels were to be stored in
memory, two trips would have to be made. 24-bit just isn't suited for 3D. That is where 32-bit colour
comes in. 24-bit and 32-bit colour depths use the same 24-bits for colour information, 8-bits for each
of the 3 primary colours. This yields a maximum colour range of over 16 million colours. 32-bit colour
"pads" its 24-bits with 8 extra bits to maximize RAM efficiency. These bits can't go unused, so they are
assigned to the alpha value. In short, the alpha value determines how transparent the pixel is.
This is very useful when creating smoke or water effects.
More Bits
Pixel position in the X and Y plans is based on the pixel's order in an image. But how is the pixel's
depth determined? That is the job of the Z-buffer. The z-buffer is usually 16-bits in 16-bit
colour mode, and 24-bits in 32-bit colour mode. The more Z bits, the more accurately the pixel can be
presented. For alpha transparencies, Z depth is very important, because a the renderer has to know if
the pixel goes behind a transparent pixel to blend with it, or if it goes in front totally blocking that
transparent pixel out.
Now, the same problem with 32-bit colour Z-buffers. 24-bits is an awkward number of bits, and it just
won't do. This is where the stencil buffer comes in. The stencil buffer is a 8-bit scratch pad
which can be used any way the programmer chooses. Most commonly, it is used as a marker for
pixels that will be reused, such as in a reflection in another object.