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.

mib_color_alpha
color "mib_color_alpha" (
    color           "input",
    scalar          "factor")
mib_color_average
color "mib_color_average" (
    color           "input",
    scalar          "factor")
mib_color_intensity
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.

mib_color_interpolate
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 ≤ 0 then only color_0 is evaluated; if the input is ≥ 1 then 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:

modeoperationcalculation
0Blend R = A·(1−Ba)·w + B·w
1Mix R = A·(1−w) + B·w
2Add R = A + B·w
3Bounded Add R = bound(A + B·w, 0, 1)
4Multiply R = A·B·w
5Bounded Multiply R = bound(A·B·w, 0, 1)
6Replace Alpha Rrgb = Argb; Ra = Ba

R is the next result, A is the previous result, B is the current color, and w is the current weight. The subscripts r, g, b, and a are red, green, blue, and alpha components. Note that mode 6 does not ensure that the resulting alpha value is valid, that is, not less than red, green, or blue. mental ray will correct alpha when storing the color in the frame buffer unless premultiplication is turned off.

mib_color_mix
color "mib_color_mix" (
    integer         "num",
    integer         "mode_0",
    integer         "mode_1",
    integer         "mode_2",
    integer         "mode_3",
    integer         "mode_4",
    integer         "mode_5",
    integer         "mode_6",
    integer         "mode_7",
    scalar          "weight_0",
    scalar          "weight_1",
    scalar          "weight_2",
    scalar          "weight_3",
    scalar          "weight_4",
    scalar          "weight_5",
    scalar          "weight_6",
    scalar          "weight_7",
    color           "color_0",
    color           "color_1",
    color           "color_2",
    color           "color_3",
    color           "color_4",
    color           "color_5",
    color           "color_6",
    color           "color_7",
    color           "color_base")
num
is the number of valid inputs. The minimum is 1 and the maximum is 8.
mode_*
are the compositing modes as described above.
weight_*
are the compositing weights w as described above.
color_*
are the composited colors B as described above.
color_base
is the base color.

Spread

Fan out one color input to up to 8 color outputs (the exact number is determined by a parameter). Each output is equal to the corresponding input, multiplied by a weight, with a given conversion. The equations are

modeoperationcalculation
0Weighted Color R = w·A
1Grayscale Color from Alpha Rrgba = w·Aa
2Grayscale Color from Average Intensity Rrgba = w·(Ar+Ag+Ab) ⁄ 3
3Grayscale Color from Weighted Intensity Rrgba = w·(0.299·Ar+ 0.587·Ag+ 0.114·Ab)
4Grayscale Color from Red Component Rrgba = w·Ar

R is the current (one of up to eight) result, w is the current weight, mode is the current conversion, and A is the input color shared by all outputs. Mode 4 is intended for converting a scalar to a grayscale color.

mib_color_spread
struct {
    color           "out_0",
    color           "out_1",
    color           "out_2",
    color           "out_3",
    color           "out_4",
    color           "out_5",
    color           "out_6",
    color           "out_7"
} "mib_color_spread" (
    color           "input",
    integer         "num",
    integer         "mode_0",
    integer         "mode_1",
    integer         "mode_2",
    integer         "mode_3",
    integer         "mode_4",
    integer         "mode_5",
    integer         "mode_6",
    integer         "mode_7",
    color           "weight_0",
    color           "weight_1",
    color           "weight_2",
    color           "weight_3",
    color           "weight_4",
    color           "weight_5",
    color           "weight_6",
    color           "weight_7")
num
is the number of valid outputs to compute. The minimum is 1 and the maximum is 8.
mode_*
are the modes mode as described above.
weight_*
are the weights w as described above.

Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.