Difference between revisions of "Reference:Color Map"

From POV-Wiki
Jump to navigation Jump to search
m (1 revision: Reference Migration Initial Load)
m (cleanup and blend mode / gamma additions))
Line 1: Line 1:
 
{{#indexentry:pigments, color maps}}
 
{{#indexentry:pigments, color maps}}
 
{{#indexentry:color_map, colour_map}}
 
{{#indexentry:color_map, colour_map}}
<p>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 <code>color_map</code> that describes how the pattern blends from one color to the next.</p>
+
{{#indexentry:blend_map}}
 +
{{#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>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 } | colour_map { COLOR_MAP_BODY }
+
   color_map { COLOR_MAP_BODY } | color_map { COLOR_MAP_BODY }
 
COLOR_MAP_BODY:
 
COLOR_MAP_BODY:
   COLOR_MAP_IDENTIFIER | COLOR_MAP_ENTRY...
+
   COLOR_MAP_IDENTIFIER | [blend_mode [BLEND_MODE]] [blend_gamma [FLOAT]] | COLOR_MAP_ENTRY...
 +
BLEND_MODE:
 +
  [0] | 1 | 2 | 3
 
COLOR_MAP_ENTRY:
 
COLOR_MAP_ENTRY:
 
   [ Value COLOR ] |  
 
   [ Value COLOR ] |  
 
   [ Value_1, Value_2 color COLOR_1 color COLOR_2 ]
 
   [ Value_1, Value_2 color COLOR_1 color COLOR_2 ]
 
</pre>
 
</pre>
<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>, is color specifications. </p>
+
 
<p class="Note"><strong>Note:</strong> The <code>[]</code> brackets are part of the actual <em>
+
<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>
COLOR_MAP_ENTRY</em>. They are not notational symbols denoting optional parts. The brackets surround each entry in the color map.</p>
+
 
<p> There may be from 2 to 256 entries in the map. The alternate spelling <code>colour_map</code> may be used.</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>Here is an example:</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>Here's an example:</p>
 
<pre>
 
<pre>
 
sphere {
 
sphere {
Line 35: Line 41:
 
<p>The pattern function <code>gradient x</code> 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.</p>
 
<p>The pattern function <code>gradient x</code> 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.</p>
 
<p>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.</p>
 
<p>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.</p>
<p>If you want areas of unchanging color you simply specify the same color for two adjacent entries. For example:</p>
+
<p>If you want areas of unchanging color you simply specify the same color for two adjacent entries.</p>
 +
<p>For example:</p>
 
<pre>
 
<pre>
 
color_map {
 
color_map {
Line 55: Line 62:
 
   }
 
   }
 
</pre>
 
</pre>
<p>You may use <code>color_map</code> with any patterns except <code>brick</code>, <code>checker</code>, <code>hexagon</code>, <code>object</code> and <code>image_map</code>. You may declare and use <code>color_map</code> identifiers. For example:</p>
+
<p>You may use <code>color_map</code> with any patterns except <code>brick</code>, <code>checker</code>, <code>hexagon</code>, <code>object</code> and <code>image_map</code>. You may also declare and use <code>color_map</code> identifiers.</p>
 +
<p>For example:</p>
 
<pre>
 
<pre>
 
#declare Rainbow_Colors=
 
#declare Rainbow_Colors=
Line 72: Line 80:
 
   }
 
   }
 
</pre>
 
</pre>
 +
 +
<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>[[Reference:Pigment_Map|Pigment Maps]] also support the {{New}} non-linear interpolation scheme.</p>

Revision as of 14:16, 19 November 2016

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.7.1 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.

There may be from 2 to 256 entries in the map. 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.