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
of colors may be between 1 and 256.
The
-values should satisfy
.
If the function returns one of these values modulo 1 for some point in space,
then
the corresponding color is used. If the value
modulo 1 lies between
and
then the two colors
and
are interpolated correspondingly.
If the value modulo 1 is smaller than
(resp. large than
) then color
(resp.
) 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
.
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
, which is 1 at 0
and vanishes outside the centered cube with side 2.
- cylindrical ...returns
, which is 1 on the
-axes
and vanishes outside the cylinder with radius 1.
- onion ...returns
, which is 1 on the unitsphere and 0 at 0.
- wood ...return
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
,
and
), 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