6.1.2 Color Mapped Patterns

Instead of aprupt changes in colors as in the color list patterns we now want to produce colors which change gradually. For this we need a function returning float values for each point in space and some way to calculate colors out of these values.

This later step is achieved by color maps, which give a table of pairs of return values between 0 and 1 and corresponding colors. The return values of the function modulo 1 are then used to interpolate between these colors. The syntax of a color_map is:

  color_map {
    [T1 color C1]
    [T2 color C2]
        ....
    [Tn color Cn]
  }
Note that here the square brackets `[' and `]' belong to the syntax and are not indicators for optional parameters. The number $ n$ of colors may be between 1 and 256. The $ T$-values should satisfy $ 0\leq T_1\leq T_2\leq\dots\leq T_n\leq 1$. If the function returns one of these values modulo 1 for some point in space, then the corresponding color is used. If the value $ T$ modulo 1 lies between $ T_i$ and $ T_{i+1}$ then the two colors $ C_i$ and $ C_{i+1}$ are interpolated correspondingly. If the value modulo 1 is smaller than $ T_1$ (resp. large than $ T_n$) then color $ C_1$ (resp. $ C_n$) is used.

Now we turn to the function assigning float values to all points in space. There are many predefined functions, like:

gradient V ...returns the length of the projection onto the vector $ V$. Thus gradient y returns the height of the point for example.
marble V ...is similar to gradient but after reaching 1 it zig-zags the values.
boxed ...returns $ 1-\min\{1,\max\{\vert X\vert,\vert Y\vert,\vert Z\vert\}$, which is 1 at 0 and vanishes outside the centered cube with side 2.
cylindrical ...returns $ 1-\min\{1,\sqrt{X^2+Z^2}\}$, which is 1 on the $ Y$-axes and vanishes outside the cylinder with radius 1.
onion ...returns $ \sqrt{X^2+Y^2+Z^2}$, which is 1 on the unitsphere and 0 at 0.
wood ...return $ \sqrt{X^2+Z^2}$ until it reaches 1 and then it zig-zags. So this gives the rings of trees. If we want to make a board of wood, we should carefully align this texture to the box and tilt it slightly.
bozo ...produces a smooth random noise (= bumps and spots)
cells ...returns for points in each unit cube a constant random value
crackle ...returns 0 for points that have equal distance to the two nearest randomly selected points. This can be used for natural stone wall.
...

If these predefined functions are not sufficient the user may supply his own function as follows:

  function { USER_FUNCTION }
with a user defined function USER_FUNCTION (in the simplest case this is just some expression in $ x$, $ y$ and $ z$), see [pov:6.1.6 User-Defined Functions]

So this type of pigment statement will look like:

  pigment { function { ... } color_map { ... } }

When all else fails one may use

Andreas Kriegl 2003-07-23