Color Calculations

By default, a color in mental ray is given in the RGB color space as a triple of R, G, B floating-point values; all internal calculations are performed in RGB. The standard alpha channel, which can be carried in the fourth A component of a color, is used to determine transparency. Its value is ranging from 0, for fully transparent, to 1 for fully opaque. mental ray uses pre-multiplied colors by default, which means that the R, G, and B components are scaled by A, and may not exceed A if it 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-pre-multiplied form to increase the precision of highly transparent pixels. By convention, mental ray and most shaders work with pre-multiplied colors, there is no precision loss here because mental ray works with floating-point values. Pre-multiplication is used to simplify compositing operations.

In general, a color is not restricted to the unit cube in RGB space. But as a final step before output, colors can be clipped to a limited color range 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 tries to maintains intensity as much as possible, but shifts the hue towards the white axis of the cube. The alpha channel will always be truncated. Desaturation color clipping may be selected with a render option or on the command line of the standalone mental ray.

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

ensures that R, G, and B never exceed A by increasing alpha if necessary while preserving RGB.
makes the same guarantee, but reduces R, G, and B accordingly to preserve the alpha channel.
applies no color clipping whatsoever.

In any of these cases, the result is clipped into the [0...1] range for all non-floating-point frame buffers.

For advanced applications, mental ray supports to store floating-point frame buffer data, often referred to as HDR or high dynamic range data, directly into capable image file formats like HDR, TIFF, or OpenEXR. In such cases, quantization and clipping is not needed and precision can be preserved. Therefore, color clipping, desaturation, and gamma correction are never applied to those frame buffers even if enabled. Instead, these operations are left to the post-processing or viewing application.

As a special case, mental ray also supports the RGBE color data format, a compressed HDR representation that can fit into standard 8-bit image formats but is still preserving the dynamic range of color values. It stores RGB colors, without alpha, as three 8-bit mantissas (in the RGB components) and a single 8-bit exponent (in the alpha component) that is shared between RGB. The shared exponent allows a large value range from 0 to 1038. As a consequence, any of the regular 8-bit color image formats may be used to store RGBE encoded images. This combines the storage efficiency of 8-bit RGB with the ability to store values greater than 1.0.

Color Profiles

mental ray supports color profiles. 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.

Copyright © 1986-2011 by mental images GmbH