next up previous contents
Next: 1.8 Geometry Up: 1. Base Shaders/A> Previous: 1.6 Illumination

1.7 Data Conversion

Color to Grayscale

Convert a color to RGBA grayscale, either by extracting the alpha component, by averaging RGB, or by weighting RGB according to a physiological color model that emphasizes green and deemphasizes red. The resulting grayscale value can also be used as a scalar. The returned R, G, B, and A components all have the same value.

      

    color "mib_color_alpha" (
        color           "input",
        scalar          "factor")

    color "mib_color_average" (
        color           "input",
        scalar          "factor")

    color "mib_color_intensity" (
        color           "input",
        scalar          "factor")

input is the color that is converted to a grayscale.

factor is a factor that the result is multiplied with. It should be set to 1.0 for correct alpha, average, and intensity values; a value of 0 will not evaluate input and return black.

Color Map Interpolation

Given a scalar or a color, perform a lookup and interpolation of a multicolor map. The map is a set (not array) of up to 8 colors. The actual number of colors is specified by a parameter.

  

    color "mib_color_interpolate" (
        scalar          "input",
        integer         "num",
        scalar          "weight_1",
        scalar          "weight_2",
        scalar          "weight_3",
        scalar          "weight_4",
        scalar          "weight_5",
        scalar          "weight_6",
        color           "color_0",
        color           "color_1",
        color           "color_2",
        color           "color_3",
        color           "color_4",
        color           "color_5",
        color           "color_6",
        color           "color_7")

input is the scalar to be looked up.

num is the number of colors in the color list. The value must be at least 1 and at most 8.

weight_* specifies the locations of colors 1..6 in the color spread. A value of 0 puts a color at the low end and 1 at the high end. The weights must be monotonically increasing. Color 0 always has a weight of 0, and color num - 1 always has a weight of 1. Only the weights between these two must be specified (that is, two fewer than colors, or num - 2 weights).

color_* specify the color spread. Only the first num colors are defined. If the input is $ \le$ 0, only color_0 is evaluated; if the input is $ \ge$1, only color_(num - 1) is evaluated. If the input is exactly equal to a weight within numerical precision, only the corresponding color is evaluated. In all other cases, exactly two neighboring colors are evaluated and interpolated.

Mix

Accepts a base color and up to 8 inputs (the exact number is determined by a parameter), each of which consists of an input color, a weight scalar, and a mode. The inputs are evaluated in sequence, each operating on the result of the previous one (the first begins with the base color, which defaults to transparent black). The following modes are supported:

mode operation  
0 Blend