You are here

Textures


  • The Pigment Statement

    • Color Lists
    • Gradients and Color Maps
    • Turbulence
    • Color Patterns

  • The Normal Statement

    • Bumps and Dents
    • Waves and Ripples

  • The Finish Statement

    • Highlights

      • Phong Highlighting
      • Specular Highlighting

    • Ambient / Scattered Light
    • Reflection
    • Refraction

As you've already seen, the texture block contains essentially all the details of an object's appearance, except for its overall shape. The general form of a texture declaration is:


texture {
   pigment { ... }
   normal  { ... }
   finish  { ... }
}


You've encountered pigment and finish already, and I'll discuss normal in a while.

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 statement

The pigment statement describes the color(s) an object has. You've seen how to use it to assign a single color to an object, but the statement is much more flexible than that.

Color Lists

Several types of pigments are color lists, which take multiple colors and apply them in some pattern on an object. The checker pigment is one example. There are two other important ones, hexagon, and brick. hexagon is similar to checker, but takes three colors instead of two, and "tiles" the object with hexagons. brick makes a brick wall-like pattern of rectangles, separated by thin seams of "mortar". brick takes two colors: one for the "bricks", and one for the mortar.

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:



Brick, checker, and hexagonal patterns

You can scale color list patterns in the same way you scale objects: to make smaller bricks, for instance, you could write:

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 Maps

Suppose 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:



Psychedelic Jupiter?

What went on here? First, the pigment statement includes the line gradient y. The gradient statement specifies which vector the changes will occur along. Though I've used a principal axis vector here (y), any vector will work, even a crazy one like <1,2,3>.

Second, there's a list of colors called color_map. The color_map tells POV-Ray where the specified colors occur. At a y of 0 -- in this example, the "equator" of the sphere -- color Red appears, whereas at a y of 1.0 -- the "North pole" -- color Violet appears.

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:

Turbulence

Suppose you get bored with the straight lines in these objects. POV-Ray has a keyword called turbulence that "mixes things up" a bit. Follow turbulence with a number, typically between 0.1 and 1, to change the amount of turbulence. Here's what our sphere looks like when we add turbulence 0.3 after the color_map list:


Color Patterns

Color patterns are among the most impressive pigment features in POV-Ray. You can use them to create realistic marbled stone or cloudy skies. The gradient we used to make the rainbow sphere is, n fact, just a simple color pattern.

To use color patterns, you must have a good understanding of the previous pigment keywords -- i.e., color_map and turbulence. To give a simple example, let's look at a igment defined in the "textures.inc" file, called "White_Marble":

#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 #declare in a couple of places, making it easier to use this pigment. Anytime you want to use it, just use pigment {White_Marble}.

The marble keyword is an example of a color pattern. Used with turbulence to create some waviness and a color map, marble simulates the appearance of real marble. For example, ere's White_Marble applied to a box:

marble.jpg

Other widely used patterns are:


  • bozo, which creates random spots (good for clouds).
  • agate, granite, which produce stone-like patterns.
  • wood, which creates patterns resembling the concentric circles and grain of wood.

Many examples of these occur in the include files "textures.inc", "stones.inc", and "woods.inc".

The Normal statement

POV-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 normal statement contains attributes that ffect the surface normal, which in turn affect the appearance of the object.

POV-Ray's objects normally come out looking very smooth. Altering the surface normal, through the normal statement, is an easy way of altering the typical smooth appearance.

Bumps and Dents

POV-Ray simulates the appearance of raised bumps or indentations in an object with the bumps and dents statements in the normal block. You follow each of these statements by a umber, typically between 0 and 2, to specify just how bumpy or dented the object is. bumps 0.2 produces gentle bumps; bumps 1.5 makes the object extremely rugged.



Left: default appearance; Center: with bumps 0.5; Right:
with dents 1.5

As with pigments, normal patterns can be scaled. bumps 0.5 scale 0.1 will create more closely spaced bumps.

Waves and Ripples

Two other useful statements are the ripples and waves statements. Both make wave patterns, with waves producing larger, deeper-looking waves than ripples. As with bumps, specify a number after waves and ripples to change the degree of "waviness".



Left: default appearance; Center: with ripples 0.5; Right:
with waves 0.5

The Finish statement

As you already know, finish controls how light interacts with an object.

Highlights

Most 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 Highlighting

Phong highlighting, named for the person who devised the model, represents a highlight with two numbers: phong and phong_size. Use phong to indicate the intensity of the highlight, and phong_size to indicate its "tightness".

phong runs from 0 to 1, with 0 representing no highlighting and 1 representing an extremely strong highlight (none of the color of the underlying object shows through at the highlight's center). phong_size is a little confusing: larger numbers indicate a smaller highlight. Think of phong_size as a sort of "reciprocal size" and you'll be all right. Typically, phong_size runs from 1 to about 200.

Specular Highlighting

Specular highlighting models highlights a little differently. Like phong highlighting, specular highlighting represents the highlight with two numbers: specular and roughness. specular and roughness are roughly equivalent to phong and phong_size respectively: use specular to define the intensity of the highlight, and roughness to define how large and diffuse it is. roughness works much as you would expect: the larger it is, the more diffuse the highlight becomes.

Both specular and roughness range from 0 to 1.

Here's an example of the different kinds of highlighting: four spheres with the same size and color but different highlights:

hilite.jpg


Upper left: phong 0.8, phong_size 5

Upper right: phong 0.8, phong_size 50

Lower left: specular 0.5, roughness 0.1

Lower right: specular 0.75, roughness 0.01

Ambient / Scattered Light

POV-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 ambient and diffuse, with a floating-point number between (and including) 0 to 1.

Use ambient to control how bright the indirectly lighted parts of the object -- those not directly lighted by a light source -- appear. If ambient is set higher than zero, the unilluminated parts of an object will still be visible. Setting ambient to its highest value, 1, will make an object appear brightly lit even without any light source.

Setting ambient to a high value does not make the object into a light source capable of illuminating other objects. It merely makes the object itself appear luminous. A high ambient value is useful for making objects that need to be self-luminous, but don't contribute appreciable light to the rest of the scene: e.g., stars, Christmas lights, LEDs, etc.

Use diffuse to control how bright the directly lighted part of the object appears. A high diffuse value makes the object seem more brightly lit. Here's an example of different values of diffuse:

diffuse.jpg

From left to right: diffuse = 0.15, 0.35, 0.75

Reflection

Occasionally you want an object to reflect all of its surroundings, rather than just have a highlight. The reflection keyword, which takes a number from 0 to 1, controls the degree of reflection. reflection 1 makes a perfect ly reflective surface. Use intermediate values for partial reflection; such objects show a mixture of their own intrinsic colors and those of the surroundings.

For metallic objects, whose reflections are colored by the color of the metal rather than their surroundings, use the keyword metallic. You don't need to specify a number; "metallicness" is either on or off.

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 finish gives the box a golden color, turns off ambient light altogether (this makes the object look more realistically reflective), adds a high degree of reflection, and makes the box "metallic", so it'll look golden. The result:

metalbox.jpg

Refraction


Often you'll want to draw an object that refracts light, like glass or liquids. For this, you'll need to do three things:

  1. Use a special form of the 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.
  2. Turn refraction on with 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.)
  3. Specify the refractive index of the object with the 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 finish in a texture, refractive properties are given in a new type of statement, interior. Furthermore the refraction keyword is unnecessary (specifying any ior other than exactly 1 automatically turns on refraction). However, refraction attributes will still work in a finish statement in POV-Ray 3.1.

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 finish turns off ambient and diffuse, so that the object will be mostly invisible (you don't really want to see much of the sphere itself, but rather the light refracted through it), colors the sphere "white" and makes it transparent, adds a little reflectivity (so that it will still look like glass), turns on refraction, and gives it an index of refraction of 1.5 (typical for many glasses). Here's the result:

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.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer