Note: all the sample images in this scene were rendered with the following color map (unless otherwise specified).
color_map {
[0.00 color rgb <0.75, 0, 0>]
[0.33 color rgb <0.75, 0.75, 0>]
[0.50 color rgb <0, 0.75, 0>]
[0.66 color rgb <0, 0, 0.75>]
[1.00 color rgb <0.75, 0, 0>]
}
This color map has very high contrast so the details of each pigment can be easily seen. Also, all the pigments were rendered without any turbulence (except for agate, which always is turbulent).
Another thing to note about agate is the fact that the turbulence
keyword has no effect on this pigment. Agate is always turbulent. The amount
of turbulence can be controlled, to some extent, with the "agate_turb"
keyword. This parameter takes a positive float value.
For more information on declaring pigments, see the pigment
section.
Bozo
The bozo pigment is a very cool and very useful pattern. It basically creates
a series of "splotches" on the object. Its color map
indexing function uses the colors from 0 to 1 without reversing. The pigment
basically works by assigning random colors to integer points in space and
interpolating the colors between those points. As a result, two points that are
"close" tend to have colors that are fairly similar while points that are "distant"
tend to have colors that are random with respect to each other. The notion
of "close" and "distant" depends on the scaling of the pigment. The bozo
pigment uses the same coloring function as spotted, but
spotted is unaffected by turbulence. Here's what
a bozo texture might look like . . .
For more information on declaring pigments, see the pigment section.
pigment {
checker
color color-a
color color-b
}
color-a and color-b are any two colors. The pigment creates a space filling pattern of colored unit cubes with the given colors. For example, the pigment
pigment {
checker
color Red
color Blue
}
would come out looking something like this
One thing to notice about the checker pigment is that it is automatically offset a little bit in each direction to prevent problems with coincident surfaces. This may produce undesirable color patterns as seen on the front face of the cube in the image.
Like most other pigments, checker responds to the turbulence modifier. The pigment can be scaled nonuniformly to produce rectangular blocks of color as well.
pigment {
color color def
}
where color def is a color defined in one of the following ways
color color name color rgb <color vec> color rgbf <color vec> color red rval green gval blue bval filter fval
In the first style, color name is the name of a declared color. A great number of (very cool) prefined color names can be found in colors.inc. They can be accessed through the include directive.
In the second style, an rgb color vector is specified for the color. The vector has three components, all floats between 0.0 and 1.0, where 0.0 represents no saturation of that color and 1.0 represents full saturation of that color. Here are a few examples
color rgb <1, 1, 1> // white color rgb <0, 0, 0> // black color rgb <1, 0.7, 0.7> // pink color rgb <0, 0.6, 0.9> // greenish blue
The third color style is similar to the second style, except a filter value is specified to make the color partially transparent. color vec in this example is a four component vector, the first three components are the same as above, and fourth float, also between 0.0 and 1.0, specifying the amount of transparency. 1.0 is a surface that is fully transparent, less than 1.0 makes colors translucent, and 0.0 makes them opaque. Note that a color that filters passes through colors in proportion to each color component. For example
color rgbf <1, 1, 1, 1> // perfectly transparent color rgbf <1, 0, 0, 1> // like red cellophane color rgbf <0.8, 0.8, 0.8, 0.4> // like frosted glass
Note that a declaration like "color rgbf <0, 0, 0, 1>" will produce a filter that is perfectly black (and hence perfectly opaque).
Finally, the fourth method of specifying colors is a more verbose variation of color specification three. Each keyword (red, green, blue, and filter) is followed by a float (between 0 and 1) that specifies the corresponding component of that color. Note that these keywords may appear in any order and are all optional (except for the first one. One must be specified or POV-Ray will whine at you). Any components that are not specified will be assumed to be 0. These keywords can also be used to modify existing colors. Any components which have not been specified can be specified with these keywords. For example, these two declarations are the same
color Red filter 0.5 color rgbf <1, 0, 0, 0.5>
For more examples of these kinds of color declarations see the standard POV-Ray file colors.inc.
Here's a sample image that was rendered with the pigment
pigment {
color rgb <0.75, 0, 0>
}
Note how the surface have no detail except for the sphere, which has a bit of shading. This is partially because of the flat pigment and partially because of the location of the light source.
color_map {
[cp0 color color spec 0]
[cp1 color color spec 1]
[cp2 color color spec 2]
/* there can be up to 20 colors in the map */
}
cp0 through cpn are floats in the range 0 to 1 that specify the location of a control point in the color map. For each control point, a color is specified. To get the color of a point in between control points, POV-Ray uses linear interpolation. Color maps must contain between 2 and 20 control points, but the value of each control point should be greater than or equal to the previous one. Here are some example color maps
color_map {
[0.0 color Red] // starts at red, then blends through
[0.33 color Green] // green,
[0.67 color Blue] // blue,
[1.0 color Red] // and back to red
}
color_map { // all colors from 0.0 to 0.5 are Yellow
[0.0 color Yellow]
[0.5 color Yellow]
[0.5 color Blue] // then, at 0.5, there is a sharp change to blue
[1.0 color Blue] // which is the color of the remainder of the map
}
color_map { // same as above, but harder to understand
[0.5 color Yellow]
[0.5 color Blue]
}
color_map { // filters blend too
[0.0 color Red]
[0.5 color White filter 1]
[1.0 color Blue]
}
Some things to keep in mind about color maps
There are a number of examples of color maps in the POV-Ray include file textures.inc.
See pigment for information about the use of frequency.
The first image shows the color map reversal at the origin, while the second was translated to remove this "feature."
For more information about declaring pigments, see the pigment section.
Granite uses the color map from 0 to 1, 0 to 1, etc, without reversing. Granite responds to turbulence, although it doesn't have any by default.
For more information on declaring pigments, see the pigment section.
pigment {
hexagon
color rgb <0.75, 0, 0>
color rgb <0, 0, 0.75>
color rgb <0, 0.75, 0>
scale 0.5
}
The pigment was scaled to give more detail about how the pigment works.
For more information about declaring pigments, see the pigment section.
image_map {
type "filename"
modifiers . . .
}
type is one of gif, tga, iff, or dump. This is followed by the filename (in quotes) which specifies the image file to be mapped.
Here we have an example of an image being mapped onto a box. The first image is the image that was mapped, and the second is the resulting scene.
The modifiers following the file type are optional. They include the aforementioned once and map_type as well as a few others.
One of these others is the interpolate keyword. Interpolation performs smoothing on the image as it is mapped. By default, POV-Ray takes the location of the ray intersection and assigns a pixel value to it. When the image map is scaled up a great deal or is of poor resolution initally, this can result in image maps that appear blocky or otherwise generally ugly. When interpolation is turned on, POV-Ray averages the values of surrounding pixels to determine intermediate values. This eliminates (for the most part) blockiness, but at the expense of tracing time. The interpolate keyword is followed by a number specifying the type of interpolation to be used. This number can be either 4 (for the Normalized Distance algorithm) or 2 (for the Bilinear algorithm). Normalized Distance is the faster algorithm, while Bilinear does a better job of picking intermediate colors. Here's an example of using the interpolate keyword
pigment {
image_map {
gif "foobar.gif"
interpolate 4
}
}
The last modifier accepted by image maps is filter values. By default, image maps are all opaque. The filter keyword can be used to change this. Filter can be used to modify specific colors, or to assign a filter value to the entire image map. Probably the best way to explain filter is through examples so here are a few
image_map {
gif "zordo.gif"
filter 0, 0.5
filter 2, 1.0
filter 7, 0.4
}
image_map {
gif "gurple.gif"
filter all 0.8
}
The first image map maps the image with the color specified by palette entry 0 (in the .GIF file) being 50% transparent. The color specified by palette entry 2 becomes 100% transparent. The color with palette entry 7 becomes 40% transparent (which should not be surprising at this point). See the section on color for an explanation of color filtering.
Image maps also respond to turbulence, which can make for some very interesting effects.
Image maps and color maps do not mix.
For more information about declaring pigments, see the pigment section.
The leopard pigment responds to turbulence, and it is said that very turbulent leopard pigments look like bozo pigments to some extent.
For more information about declaring pigments, see the pigment section.
For more information on declaring textures, see the pigment section.
For more information on declaring pigments, see the pigment section.
Note that the sphere is entirely one color. This is because the pigment is centered at the enter of the sphere and so each point one the sphere lines up with the same color in the color map.
For more information on declaring pigments, see the pigment section.
pigment {
// One of these is required
pigment type /* OR */
color color /* OR */
image_map {
/* image map specifications */
}
// all the following are optional
color_map {
/* color map entries */
}
frequency frequency
lambda lambda val
octaves number of octaves
omega omega val
phase phase
quick_color color
turbulence turbulence val or vec
/* any transformations go here */
}
Any number of transformations (rotations, translations, and scales) may follow the pigment declaration, but must specified after the last pigment modifier.
A pigment consists of three major parts, first the pigment type, then the color map, and finally the turbulence. The color map and the turbulence are optional. The first part, pigment type is one of the following: agate, bozo, checker, gradient, granite, hexagon, leopard, marble, mandel, onion, , or wood. See their individual sections for more specific information on each (as well as sample images).
The second type of modifier is the color map. The specification of a color map is covered in some detail above. The two color map modifiers are frequency, which stretches or compresses the color map, and phase, which shifts the colors in the map.
The third part of the pigment is the turbulence specification. Turbulence is the "most optional" of the three parts. There are a number of pigments which will look fine without turbulence (such as bozo), and some which look rather lame without turbulence (such as marble) and even some which don't even respond to turbulence (such as spotted). Turbulence is basically used to mix up a pigment a little (or a lot). This can add life to a pigment. It can also make some pigments look weird. The modifiers lambda, octaves, and omega can be used to tweak the turbulence to achieve the exact effect you're looking for.
sphere {
gradient x
color_map {
[0.0 color Red]
[1.0 color Yellow]
}
turbulence 0.8
quick_color Aquamarine
}
will instruct POV-Ray to create a turbulent gradient pigment at +Q6 and above, and otherwise just color the sphere Aquamarine. You can use the quick_color modifier to distinguish two objects in a quick rendering. Note that giving an object a solid color pigment will automatically set the quick color to the same color. You can override this by explicitly specifying a quick color, though.
There are some more samples over with the frequency section. For more information on declaring pigments, see the pigment section.
For more information on declaring pigments, see the pigment section.
turbulence 0.8 // stir up the pigment equally in all directions
turbulence <0, 0.9, 0.3> // no turbulence in the x direction, a lot in
// the y direction and a little in the z
// direction
turbulence x // major turbulence only in the x direction
All of the numbers, whether individual floats or vector components, should be between 0.0 and 1.0 inclusive. High numbers mean lots of turbulence, low numbers mean only a little turbulence. Here's an example of what turbulence does. Both images use a marble pigment, but only the second was rendered with turbulence (turbulence 0.8, to be exact).
The way POV-Ray implements turbulence is quite interesting. In a normal pigment, POV-Ray simples determines the color of the pixel at each point on the surface of the object and colors the object with that. Turbulence works by taking a number of semi-random steps and using the color at the destination point. In essence, it constructs a pointer which says, "use that color over there." The "random" number generator used to produce these steps is a function of original point. Hence, points that are near each other initially tend to end up with similar colors, while points that are distant tend to end up with random colors (with respect to each other). The "random" number generator is also deterministic, so rendering a scene file with turbulence will always result in the same image (good for creating animations).
Here's a more in depth description of the turbulence function which will make its modifiers (lambda, octaves, and omega) make a little more sense. Turbulence works by first selecting a direction and moving so far that way. Then it picks a new direction and moves not-quite-as-far in that direction. Then it picks yet another direction and moves not-quite-not-quite-as-far in that direction. It uses a function called DNoise to generate these random steps. The overall magnitude of these steps is controlled by the parameter given to turbulence. Hence large amounts of turbulence create very large steps. The total number of steps taken is controlled by the octaves parameter. The default number of octaves is 6. This is a reasonable number and will do fine for most textures. Decreasing the number or octaves (to, say, 2) can create interesting effects. Increasing it will have only a marginal effect. This is because the length of each step falls off exponentially. The rate at which the step length falls off is determined by the omega value. Each subsequent step in the turbulence is omega times as long as the previous one. The default omega value is 0.5. Omegas are typically less than 1.0. High values or omega (0.8, 0.9, whatever) tend to make the turbulence more random, while low values (say, 0.1, 0.2) tend to smooth the pigment out a lot. The third modifier for turbulence is the lambda parameter. This controls the "randomness" of each step. Lambdas that are close to 1.0 cause each of the steps to be in approximately the same direction. Higher lambdas increase the randomness of the direction of each step. The default value is 2.0. Lambda should be greater than or equal to 1.0.
For more information about declaring pigments, see the pigment section.
The Online POV-Ray Tutorial © 1996 The Online POV-Ray Tutorial ThinkQuest Team