Site Tools


documentation:development:opera:pf25:ppgfldr:ggsfldr:gpgfldr:2gpgd

The CLUT Sets


Color values coming out of the background pixel detector enter a CLUT set. 3DO graphics hardware provides two sets of CLUTs:

  • Custom CLUT set, which contains writable color registers that can be set by a task.
  • Fixed CLUT set in which the CLUTs contain fixed linear values.

Each CLUT set contains three CLUTs: one each for red, green, and blue. Each CLUT has 32 registers containing 8-bit values for red, green, or blue (depending on the color to which the CLUT is dedicated). Each CLUT also has a 33rd register that contains an 8-bit value used for a background pixel.

The Custom CLUT Set

The values in the custom CLUT set registers can be completely rewritten with display control commands in the VDL to provide a completely new palette of colors for frame buffer pixels. Because display control commands are executed just before a specified line of the display, you can change palettes at any line. This means you can completely change palettes for horizontal strips of the display. You can even set a completely different palette for each line of the display if you don't mind quite a bit of processing during a horizontal blank.

The 8-bit values contained in the CLUTs are normally linear ascending. That is, they ascend in even intervals from a low value in register 0 to a high value in register 31. For example, they can ascend in steps of 8-from 0 in register 0 to 255 in register 31-0, 8, 16, 24, 33, 41, and so on. The reason for this is that the cel engine assumes a linear palette when it scales color values to create lighting effects. For example, if the cel engine multiplies the red, green, and blue components of a 15-bit color value by 1.5, it assumes that the higher resulting color value will result in a brighter (or darker) color, which is true if the palette is linear and is either ascending or descending. If the palette isn't linear, it's hard to predict the result of scaling or averaging color values in the cel engine. You can, of course, have some fun with this if you want to create a completely nonlinear color palette in the custom CLUT set and then use it to delve into some very odd cel processing results.

The Fixed CLUT Set

The fixed CLUT set always contains a completely linear ascending color palette because it simply uses the 5-bit red, green, and blue values as the most significant 5 bits of the 8-bit red, green, and blue values it sends out. The least-significant 3 bits it must add to the 5-bit value can be set to either 0, a duplicate of the 3 most significant bits, or a random value. The random value in the least-significant bits lightly dithers the resulting colors to reduce banding between adjacent color areas. (Banding is the visual effect in a color digital picture that looks something like a contour map-you clearly see the boundaries between one color and another, even if the colors are very similar. Dithering breaks up the boundaries for a smooth gradation between colors.)

The fixed CLUT set provides dependable cel engine results but you won't be able to change it on the fly for a new palette. The primary reason the fixed CLUT set exists is so that a known palette is always available, even if the custom palette has been tweaked into color madness. If one task controls the display and creates its own custom palette, a second task that doesn't own the display can always use the fixed palette and know the results for certain.

Choosing a CLUT Set

The VDLP usually controls which of the two CLUT sets-custom or fixed-is used for interpreting incoming pixels. However, in P555 and P5541 display modes, each pixel chooses its own CLUT set with its color-set bit. If the custom CLUT set is cleverly programmed to contain values not available in the fixed CLUT set, then pixels in P555 mode can choose color values from either CLUT set, providing a total palette of 65,536 possible colors, double the normal palette of 32,768 possible colors.

Handling Background Pixels

Any pixel with a color value set completely to 0 is a special case: it has been declared a background pixel by the background pixel detector and the CLUT set doesn't handle the pixel as it normally would. It doesn't use the contents of the 0 registers in the red, green, and blue CLUTs for the pixel's color; instead, it uses the contents of the background register in each CLUT. The background register is a 33rd register that contains a special value (0 in the fixed CLUT set, any value in the custom CLUT set). The red, green, and blue background values merge together to give the background pixel its own 24-bit color value. If SlipStream doesn't replace the background pixel with a pixel from another source, then the pixel appears on the display with its background color.

The special background registers allow you to set nonblack background colors without throwing off the linear palette. To understand how this works, consider how background pixels would work without a special background register: you're working with a linear palette that ascends from 0 in the lowest register to 255 in the highest register. If you want to set white as the background color, you'd have to set the lowest register in each CLUT to 255 (maximum R, G, and B equals white). Each time a background pixel comes through, it receives a red value of 255, a green value of 255, and blue value of 255. But when a pixel intended to be cyan comes through with a 15-bit color value specifying red=0 (the lowest register), green=31 (the highest register), and blue=31 (the highest register), the red value comes out as 255 instead of 0 because you changed the 0 register to accommodate the background pixel. The resulting pixel is white instead of cyan. By including a background pixel register in each CLUT, the CLUT set allows you to set a special background color without disturbing the linear palette.

Passing on Color Values

Once each 15-bit color value coming into the CLUT set has been converted into a 24-bit color value, the 24-bit value moves through the rest of the display generator. All of the following components are designed to work with 24-bit color.

documentation/development/opera/pf25/ppgfldr/ggsfldr/gpgfldr/2gpgd.txt · Last modified: 2022/10/10 16:53 by 127.0.0.1