home << prev next >> contents  


Color Calculations

By default all colors in mental ray are given in the RGBA color space and all internal calculations are performed in RGBA. The alpha channel is used to determine transparency; 0 means fully transparent and 1 means fully opaque. mental ray uses premultiplied colors, which means that the R, G, and B components are scaled by A and may not exceed A if A is less than 1.0. This becomes significant only when colors are stored in 8-bit or 16-bit frame buffers because the store operation requires quantization and clipping of arbitrary floating-point values to the fixed integer ranges of the frame buffer formats. Optionally, RGBA colors may be stored in the output image in non-premultiplied form to increase the precision of highly transparent pixels, but by convention, mental ray and all shaders work with premultiplied colors (there is no precision loss here because mental ray works with floating-point values). Premultiplication is used to simplify compositing operations.

Internally, colors are not restricted to the unit cube in RGB space. As a final step before output, colors are clipped using one of two methods. By default, the red, green and blue values are simply truncated. Optionally, colors may be clipped using a desaturation method which maintains intensity (if possible), but shifts the hue towards the white axis of the cube. Desaturation color clipping may be selected with either the -desaturate on option on the command line or desaturate on in the options block in the scene. The alpha channel is always truncated.

mental ray also supports three different color clipping modes that control how premultiplied colors are clipped before storing in the frame buffer:

RGB

ensures that R, G, and B never exceed alpha by increasing alpha if necessary, and preserving R, G, and B.

alpha

makes the same guarantee, but reduces R, G, and/or B to preserve the alpha channel.

raw

applies no color clipping whatever.

In any case, the result is clipped into the 0...1 range.

As a special case, mental ray supports the floating-point TIFF image file format, and a proprietary floating-point format (ctfp), that do not require any quantization, clipping, or loss of precision. Therefore, desaturation and color clipping are never applied.

mental ray 3.1 also supports the RGBE high dynamic range color data format. Its stores RGB colors (no alpha) as floating-point values with an 8-bit mantissa and an 8-bit shared exponent. The shared exponent allows a large value range from 0 to (actually more, but the internal calculations use floats), and has the effect that the ratio between the largest and the smallest component cannot exceed 255. It combines the storage efficiency of 8-bit RGB with the ability to store values greater than 1.0.

Starting with version 3.4 mental ray supports color profiles. In version 3.5 the following color profiles are predefined:

name description
micsSRGB, micsHDTV sRGB, no gamma correction
micsSRGBg sRGB, with gamma correction
micsHDTVg Rec. 709 (HDTV), with gamma correction
micsNTSC NTSC, no gamma correction
micsSharpRGB A wide gamut color space
micsLineRGB R: 700nm, G: 550nm, B: 432nm
micsBoxRGB R: 575-730nm, G: 500-575nm, B: 380-500nm
micsCIEXYZ CIE XYZ (1931, 2 degree), output only
micsCIELab perceptionally uniform CIE L*a*b*, output only
micsCIELuv perceptionally uniform CIE L*u*v*, output only
micsSpectrum spectral rendering, needs special shaders, rendering only
micsSimpleCMY simple printer output with D50 white point
micsSimpleCMYK simple printer output with D50 white point
Color profiles are enabled by giving a profile in the options block
      options "opt"
           colorprofile "profile_name"
      end options
  

The above color profile determines the rendering color space. The use of color profiles implies a floating point color frame buffer. Colors in the frame buffer are stored in an internal color space, that is, the colors of the rendering color space are transformed to internal color space before they are written to the color frame buffer. The CIE color profiles are in general unsuitable for rendering purposes, but they may be used for output purposes. The sRGB and HDTV color spaces differ only in their gamma values. Ideally gamma correction is performed by the viewing device. However, if the output image format has a resolution of less than twelve bits per color channel, then banding artifacts may result. For this reason it may be desirable to perform the gamma correction before the image is written out. Therefore mental ray offers the gamma corrected profiles "micsSRGBg" and "micsHDTVg" as well as the not gamma corrected "micsSRGB" with its alias "micsHDTV".

Color parameters of shaders may also be flagged with a color profile. The application of such a transformation cannot be automated, since which color arguments of a shader should be transformed to render color space depends on the inner workings of the involved shader. As a rule of thumb, color parameters describing material properties should not be transformed, while color parameters describing light properties should be transformed. If a color parameter is not flagged with a color profile, then it is assumed to be given in render color space.

home << prev next >> contents  


Copyright © 1986-2007 by mental images GmbH