C
LUT is short for
Color
Look
Up
Table. It refers to a technique used in older
hardware to display
bitmaped
images. Instead of storing the color in the
pixel's
memory location, a CLUT based system stores an
index that refers to a
table of component color values.CLUTs are also refered to as
palettes. The diagram below serves to illustrate how a CLUT works. In the pixel's memory
address, a value of 5 is stored. This value is used to look up the 5
th entry in the color table which ends up being
purple.
The value of a pixel
|
| Index Red Green Blue
| | 0 | 20 | 40 | 10 |
V | 1 | 10 | 40 | 30 |
| 3 | 2 | 5 | 0 | | 2 | 35 | 12 | 11 |
| 1 | 1 | | | 1 | | 3 | 35 | 12 | 11 |
| 2 | 3 | | | 2 | | 4 | 35 | 12 | 11 |
| 2 | 2 | =====The lookup=====>| 5 | 75 | 40 | 75 | =====>The Pixels Color (purple)
Simple 4x4 pixel bitmap The color lookup table
The main reason that this technique is used is to save memory at the cost of reducing the colors available. Let's say you have a
screen resolution of
640x480 and you're using
24 bit color. 24 bits is 3
bytes per pixel and that gives you 640x480x3 or 921,600 bytes needed to store the image. If you were using a CLUT system, that same image could use 640x480x1 or 307,200 bytes, which is 1/3
rd the size. Of course, the first image could contain over 16
million different colors (if it had enough pixels - and it doesn't), while the CLUT image could only contain
256 different colors.
There are a few more cool things that you can do with a clut system. You can change the CLUT while the image is displayed to create an
illusion of movement. This technique is often refered to as
color cycling or
palette animation, and it involves stuffing the CLUT with a bunch of different palettes, in a sequence.
Video games often use this technique to create the illusion of flowing water, glowing hot lava, or flashing lights.
If you're doing
real-time 3D graphics you can create a scene with
texture maps using one CLUT representing a certain time of day, for example, morning. You could then create another CLUT that would work for the same texture maps but would represent another time of day, mid-day for example. If you smoothly
fade from one CLUT to the other, you can create the illusion of changing time of day in your
3D game.