Color Map
Reference

From POV-Wiki
Jump to: navigation, search

Most of the color patterns do not use abrupt color changes of just two or three colors like those in the brick, checker or hexagon patterns. They instead use smooth transitions of many colors that gradually change from one point to the next. The colors are defined in a pigment modifier called a color_map that describes how the pattern blends from one color to the next. New in version 3.8 non-linear color map interpolation support has been added.

Each of the various pattern types available is in fact a mathematical function that takes any x, y, z location and turns it into a number between 0.0 and 1.0 inclusive. That number is used to specify what mix of colors to use from the color map.

The syntax for color_map is as follows:

COLOR_MAP:
  color_map { COLOR_MAP_BODY } | color_map { COLOR_MAP_BODY }
COLOR_MAP_BODY:
  COLOR_MAP_IDENTIFIER | [blend_mode [BLEND_MODE]] [blend_gamma [FLOAT]] | COLOR_MAP_ENTRY...
BLEND_MODE:
  [0] | 1 | 2 | 3
COLOR_MAP_ENTRY:
  [ Value COLOR ] | 
  [ Value_1, Value_2 color COLOR_1 color COLOR_2 ]

Where each Value_n is a float values between 0.0 and 1.0 inclusive and each COLOR_n, are color specifications.

Note: The [] brackets that are part of the actual COLOR_MAP_ENTRY should not confused with the symbols denoting optional syntax.

In previous versions there had to be from 2 to 256 entries in the map. A Change in version 3.8 has removed the upper restriction. The alternate spelling colour_map can also be used.

Here's an example:

sphere {
  <0,1,2>, 2
  pigment {
    gradient x       //this is the PATTERN_TYPE
    color_map {
      [0.1  color Red]
      [0.3  color Yellow]
      [0.6  color Blue]
      [0.6  color Green]
      [0.8  color Cyan]
      }
    }
  }

The pattern function gradient x is evaluated and the result is a value from 0.0 to 1.0. If the value is less than the first entry (in this case 0.1) then the first color (red) is used. Values from 0.1 to 0.3 use a blend of red and yellow using linear interpolation of the two colors. Similarly values from 0.3 to 0.6 blend from yellow to blue.

The 3rd and 4th entries both have values of 0.6. This causes an immediate abrupt shift of color from blue to green. Specifically a value that is less than 0.6 will be blue but exactly equal to 0.6 will be green. Moving along, values from 0.6 to 0.8 will be a blend of green and cyan. Finally any value greater than or equal to 0.8 will be cyan.

If you want areas of unchanging color you simply specify the same color for two adjacent entries.

For example:

color_map {
  [0.1  color Red]
  [0.3  color Yellow]
  [0.6  color Yellow]
  [0.8  color Green]
  }

In this case any value from 0.3 to 0.6 will be pure yellow.

The first syntax version of COLOR_MAP_ENTRY with one float and one color is the current standard. The other double entry version is obsolete and should be avoided. The previous example would look as follows using the old syntax.

color_map {
  [0.0 0.1  color Red color Red]
  [0.1 0.3  color Red color Yellow]
  [0.3 0.6  color Yellow color Yellow]
  [0.6.0.8  color Yellow color Green]
  [0.8 1.0  color Green color Green]
  }

You may use color_map with any patterns except brick, checker, hexagon, object and image_map. You may also declare and use color_map identifiers.

For example:

#declare Rainbow_Colors=
color_map {
  [0.0   color Magenta]
  [0.33  color Yellow]
  [0.67  color Cyan]
  [1.0   color Magenta]
  }
object {
  My_Object
  pigment {
    gradient x
    color_map { Rainbow_Colors }
    }
  }

The possible values for blend_mode and their descriptions are as follows:

  • 0: Color interpolation is performed in the working gamma space as defined by assumed_gamma (default)
  • 1: Color interpolation is performed in the linear color space
  • 2: Color interpolation is performed in the gamma space defined by blend_gamma (default is 2.5)
  • 3: Chromatic interpolation is performed in the linear space while brightness interpolation is performed in the gamma space defined by blend_gamma

Pigment Maps also support the New non-linear interpolation scheme.

Personal tools
Namespaces
Variants
Actions
Content
Other Pages
Toolbox