Difference between revisions of "Reference:Color Map"

From POV-Wiki
Jump to navigation Jump to search
m (cleanup and blend mode / gamma additions))
m (corrections)
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
{{#indexentry:blend_map}}
 
{{#indexentry:blend_map}}
 
{{#indexentry:blend_gamma}}
 
{{#indexentry:blend_gamma}}
<p>Most of the color patterns do not use abrupt color changes of just two or three colors like those in the <code>brick</code>, <code>checker</code> or <code>hexagon</code> 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 <code>color_map</code> that describes how the pattern blends from one color to the next. {{New}} in version 3.7.1 non-linear color map interpolation support has been added.</p>
+
<p>Most of the color patterns do not use abrupt color changes of just two or three colors like those in the <code>brick</code>, <code>checker</code> or <code>hexagon</code> 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 <code>color_map</code> 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.</p>
 
<p>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.</p>
 
<p>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.</p>
 
<p>The syntax for <code> color_map</code> is as follows:</p>
 
<p>The syntax for <code> color_map</code> is as follows:</p>
 +
 
<pre>
 
<pre>
 
COLOR_MAP:
 
COLOR_MAP:
   color_map { COLOR_MAP_BODY } | color_map { COLOR_MAP_BODY }
+
   color_map { COLOR_MAP_BODY } |
 +
  colour_map { COLOR_MAP_BODY }
 
COLOR_MAP_BODY:
 
COLOR_MAP_BODY:
   COLOR_MAP_IDENTIFIER | [blend_mode [BLEND_MODE]] [blend_gamma [FLOAT]] | COLOR_MAP_ENTRY...
+
   COLOR_MAP_IDENTIFIER |
 +
  [BLEND_MAP_MODIFIERS...] COLOR_MAP_ENTRY...
 +
BLEND_MAP_MODIFIERS:
 +
  blend_mode BLEND_MODE |
 +
  blend_gamma FLOAT
 
BLEND_MODE:
 
BLEND_MODE:
   [0] | 1 | 2 | 3
+
   0 | 1 | 2 | 3
 
COLOR_MAP_ENTRY:
 
COLOR_MAP_ENTRY:
 
   [ Value COLOR ] |  
 
   [ Value COLOR ] |  
Line 19: Line 25:
  
 
<p>Where each <em><code>Value_n</code></em> is a float values between 0.0 and 1.0 inclusive and each <em>COLOR_n</em>, are color specifications.</p>
 
<p>Where each <em><code>Value_n</code></em> is a float values between 0.0 and 1.0 inclusive and each <em>COLOR_n</em>, are color specifications.</p>
 +
 +
<p>The possible values for <code>blend_mode</code> and their descriptions are as follows:</p>
 +
<ul>
 +
  <li><strong>0:</strong> Color interpolation is performed in the working gamma space as defined by <code>assumed_gamma</code> (default)</li>
 +
  <li><strong>1:</strong> Color interpolation is performed in the linear color space</li>
 +
  <li><strong>2:</strong> Color interpolation is performed in the gamma space defined by <code>blend_gamma</code> (default is 2.5)</li>
 +
  <li><strong>3:</strong> Chromatic interpolation is performed in the linear space while brightness interpolation is performed in the gamma space defined by <code>blend_gamma</code></li>
 +
</ul>
  
 
<p class="Note"><strong>Note:</strong> The <code>[]</code> brackets that are part of the actual <em>COLOR_MAP_ENTRY</em> should not confused with the symbols denoting optional syntax.</p>
 
<p class="Note"><strong>Note:</strong> The <code>[]</code> brackets that are part of the actual <em>COLOR_MAP_ENTRY</em> should not confused with the symbols denoting optional syntax.</p>
  
<p>There may be from 2 to 256 entries in the map. The alternate spelling <code>colour_map</code> can also be used.</p>
+
<p>In <em>previous</em> versions there <em>had</em> to be from 2 to 256 entries in the map. A {{Change}} in version 3.8 has removed the upper restriction. The alternate spelling <code>colour_map</code> can also be used.</p>
<p>Here's an example:</p>
+
<p>Here's a simple example:</p>
 
<pre>
 
<pre>
 
sphere {
 
sphere {
Line 81: Line 95:
 
</pre>
 
</pre>
  
<p>The possible values for <code>blend_mode</code> and their descriptions are as follows:</p>
+
<p>See also: [[Reference:Pigment Map|Pigment Maps]].</p>
<ul>
 
  <li><strong>0:</strong> Color interpolation is performed in the working gamma space as defined by <code>assumed_gamma</code> (default)</li>
 
  <li><strong>1:</strong> Color interpolation is performed in the linear color space</li>
 
  <li><strong>2:</strong> Color interpolation is performed in the gamma space defined by <code>blend_gamma</code> (default is 2.5)</li>
 
  <li><strong>3:</strong> Chromatic interpolation is performed in the linear space while brightness interpolation is performed in the gamma space defined by <code>blend_gamma</code></li>
 
</ul>
 
 
 
<p>[[Reference:Pigment_Map|Pigment Maps]] also support the {{New}} non-linear interpolation scheme.</p>
 

Latest revision as of 10:45, 24 July 2017

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 } |
  colour_map { COLOR_MAP_BODY }
COLOR_MAP_BODY:
  COLOR_MAP_IDENTIFIER |
  [BLEND_MAP_MODIFIERS...] COLOR_MAP_ENTRY...
BLEND_MAP_MODIFIERS:
  blend_mode BLEND_MODE |
  blend_gamma FLOAT
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.

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

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 a simple 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 }
    }
  }

See also: Pigment Maps.