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:
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 1038 (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.