Email: nexusmail at this Web site address
As you've already seen, the
texture {
pigment { ... }
normal { ... }
finish { ... }
}
You've encountered Thus far, the POV-Ray code I've shown normally used pre-defined attributes for pigments and finishes. For example, I used the finish "Mirror" to make something shiny, and the pre-defined colors Red, White, Black, etc. in various places. However, more fundamental terms underlie all of these. Once you understand the more fundamental terms, you can create all sorts of textures, to represent the appearance of just about any object you've ever seen, and many only imagined. The Pigment statementThe Color ListsSeveral types of pigments are color lists, which take multiple colors and apply them in some pattern on an object. The For example, to create a hexagonally-tiled floor, you would write something like:
plane {y, 0
pigment {hexagon color Red, color Green, color Blue}
}
Here's an example of the three pigment types:
You can
plane {x, 0 pigment {brick color Red, color White scale 0.25}
Color list patterns can also be rotated or translated, using the appropriate keywords. Gradients and Color MapsSuppose you wanted to create your own coloring patterns? POV-Ray supports something called color maps, which allow you to specify a set of colors to be used for coloring an object. A color map is simply a list of colors. You also have to specify how to use these colors. The simplest way to do that is the gradient, which smoothly changes the colors along a given direction. Let's use a color map and a gradient to create a rainbow-colored sphere. The POV-Ray code for this looks like:
#include "colors.inc"
camera {location <0,0,-5> look_at <0,0,0>}
light_source {<0,0,-30> color White}
sphere {<0,0,0>, 1
pigment {
gradient y
color_map {
[0 color Red]
[0.2 color Orange]
[0.4 color Yellow]
[0.6 color Green]
[0.8 color Blue]
[1.0 color Violet]
}
}
}
and the rendered result looks like this:
What went on here? First, the Second, there's a list of colors called Note that the gradient goes in both the positive and negative directions. Furthermore, if the colored object is larger than +/- 1.0 the gradient will repeat itself. Let's increase the radius of the sphere to 2.0 and re-render:
TurbulenceSuppose you get bored with the straight lines in these objects. POV-Ray has a keyword called
Color PatternsColor patterns are among the most impressive pigment features in POV-Ray. You can use them to create realistic marbled stone or cloudy skies. The To use color patterns, you must have a good understanding of the previous pigment keywords -- i.e.,
#declare White_Marble_Map =
color_map {
[0.0, 0.8 color rgb <0.9, 0.9, 0.9>
color rgb <0.5, 0.5, 0.5>]
[0.8, 1.0 color rgb <0.5, 0.5, 0.5>
color rgb <0.2, 0.2, 0.2>]
}
#declare White_Marble =
pigment {
marble
turbulence 1
color_map {White_Marble_Map}
}
Notice how this uses The
Other widely used patterns are:
Many examples of these occur in the include files "textures.inc", "stones.inc", and "woods.inc". The Normal statementPOV-Ray defines something called the "surface normal", which is, in effect, a vector normal (perpendicular) to the surface of an object at a given point. The POV-Ray's objects normally come out looking very smooth. Altering the surface normal, through the Bumps and DentsPOV-Ray simulates the appearance of raised bumps or indentations in an object with the
As with pigments, normal patterns can be scaled. Waves and RipplesTwo other useful statements are the
The Finish statementAs you already know, HighlightsMost objects reflect light sources strongly, reflecting back some of the light as a "highlight". Highlights strongly increase the realism of a rendered object. POV-Ray has two schemes for representing highlights. Phong HighlightingPhong highlighting, named for the person who devised the model, represents a highlight with two numbers:
Specular HighlightingSpecular highlighting models highlights a little differently. Like phong highlighting, specular highlighting represents the highlight with two numbers: Both Here's an example of the different kinds of highlighting: four spheres with the same size and color but different highlights:
Ambient / Scattered LightPOV-Ray can also represent the effect of indirect lighting -- that coming from sources other than direct illumination by a light source. Specify indirect lighting by using Use Setting Use
ReflectionOccasionally you want an object to reflect all of its surroundings, rather than just have a highlight. The For metallic objects, whose reflections are colored by the color of the metal rather than their surroundings, use the keyword Here's an example of a metallic box made of gold:
box {<0,0,0>, <1,1,1> pigment {color Gold}
finish {ambient 0 diffuse 0.5
specular 0.75 roughness 0.001
reflection 0.99 metallic}
rotate 30*y}
Here, the
RefractionOften you'll want to draw an object that refracts light, like glass or liquids. For this, you'll need to do three things: color statement. To make an object transmit light, you must specify four numbers in the color vector rather than the usual three. The normal syntax for this is: color rgbf <n,n,n, n> where the "f" stands for "filter", and the fourth number represents the degree of filtering, ranging from 0 (opaque) to 1 (totally transparent). The transmitted light will have a color based on the first 3 numbers, which are the same rgb values we've used before. color rgbf <1,0.5,0.5,1> would give a rosy red tint to the light passing through the object. refraction 1. refraction is one of those keywords that requires an integer, either 1 or 0. (Actually, you can specify other numbers, but the result almost certainly won't be what you want.)ior statement. Refractive index is a measure of how strongly an object refracts light. ior is typically between 1 and 2, though there is no limit on what values can be set. Note: Refraction is one thing that changed from POV-Ray 3.0 to POV-Ray 3.1. Instead of specifying them in Let's take our sphere from the old checkerboard + sphere demo and make it refractive:
plane {y, 0 pigment {checker color Red, color White}}
sphere{<1,1,1>, 1 pigment {color rgbf <1,1,1,1>}
finish {ambient 0 diffuse 0
specular 0.25 roughness 0.001
reflection 0.1
refraction 1 ior 1.5}
rotate 30*y}
Here, the
Pretty clever! The sphere, in fact, acts as a crude lens; appropriately, looking through it, you can see a distorted (and, in places, magnified) upside-down image of the checkered floor. |
|||











