Section 4.7.3
Creating Color Patterns

You can do more than assign a solid color to an object. You can create complex patterns in the pigment block. Consider this example:

sphere { <0, 1, 2>, 2 texture { pigment { wood color_map { [0.0 color DarkTan] [0.9 color DarkBrown] [1.0 color VeryDarkBrown] } turbulence 0.05 scale <0.2, 0.3, 1> } finish { phong 1 } } }

The keyword wood specifies a pigment pattern of concentric rings like rings in wood. The color_map specifies that the color of the wood should blend from DarkTan to DarkBrown over the first 90% of the vein and from DarkBrown to VeryDarkBrown over the remaining 10%. The turbulence slightly stirs up the pattern so the veins aren't perfect circles and the scale factor adjusts the size of the pattern.

Most patterns are set up by default to give you one feature across a sphere of radius 1.0. A feature is very roughly defined as a color transition. For example, a wood texture would have one band on a sphere of radius 1.0. In this example we scale the pattern using the scale keyword followed by a vector. In this case we scaled 0.2 in the x direction, 0.3 in the y direction and the z direction is scaled by 1, which leaves it unchanged. Scale values larger than one will stretch an element. Scale values smaller than one will squish an element. And a scale value of one will leave an element unchanged.


Section 4.7.4
Pre-defined Textures

POV-Ray has some very sophisticated textures pre-defined in the standard include files glass.inc , metals.inc , stones.inc and woods.inc . Some are entire textures with pigment , normal and/or finish parameters already defined. Some are just pigments or just finishes. Change the definition of our sphere to the following and then re-render it:

sphere { <0, 1, 2>, 2 texture { pigment { DMFWood4 // pre-defined in textures.inc scale 4 // scale by the same amount in all // directions } finish { Shiny } // pre-defined in finish.inc } }

The pigment identifier DMFWood4 has already been scaled down quite small when it was defined. For this example we want to scale the pattern larger. Because we want to scale it uniformly we can put a single value after the scale keyword rather than a vector of x, y, z scale factors.

Look through the file textures.inc to see what pigments and finishes are defined and try them out. Just insert the name of the new pigment where DMFWood4 is now or try a different finish in place of Shiny and re-render your file.

Here is an example of using a complete texture identifier rather than just the pieces.

sphere { <0, 1, 2>, 2 texture { PinkAlabaster } }

Section 4.8
Advanced Texture Options

The extremely powerful texturing ability is one thing that really sets POV-Ray apart from other raytracers. So far we have not really tried anything too complex but by now you should be comfortable enough with the program's syntax to try some of the more advanced texture options.

Obviously, we cannot try them all. It would take a tutorial a lot more pages to use every texturing option available in POV-Ray. For this limited tutorial, we will content ourselves to just trying a few of them to give you an idea of how textures are created. With a little practice, you will soon be creating beautiful textures of your own.


Section 4.8.1
Pigment and Normal Patterns

Previous versions of POV-Ray made a distinction between pigment and normal patterns, i. e. patterns that could be used inside a normal {... } or pigment {... } statement. With POV-Ray 3.0 this restriction was removed so that all patterns listed in section "Patterns" can be used as a pigment or normal pattern.

Section 4.8.2
Pigments

Every surface must have a color. In POV-Ray, this color is called a pigment . It does not have to be a single color. It can be a color pattern, a color list, or even an image map. Pigments can also be layered one on top of the next so long as the uppermost layers are at least partially transparent so the ones beneath can show through. Let's play around with some of these kinds of pigments.

Create a file called texdemo.pov and edit it as follows:

#include "colors.inc" camera { location <1, 1, -7> look_at 0 angle 36 } light_source { <1000, 1000, -1000> White } plane { y, -1.5 pigment { checker Green, White } } sphere { <0,0,0>, 1 pigment { Red } }

Giving this file a quick test render at 200x150 -A we see that it is a simple red sphere against a green and white checkered plane. We will be using the sphere for our textures.


Section 4.8.2.1
Using Color List Pigments

Before we begin you should note that we have already made one kind of pigment, the color list pigment. In the previous example we have used a checkered pattern on our plane. There are two other kinds of color list pigments, brick and hexagon . Let's quickly try each of these. First, change the plane's pigment as follows:

pigment { hexagon Green, White, Yellow }

Rendering this we see a three-color hexagonal pattern. Note that this pattern requires three colors. Now change the pigment to...

pigment { brick Gray75, Red rotate -90*x scale .25 }

Looking at the resulting image see that the plane now has a brick pattern. Note that we had to rotate the pattern to make it appear correctly on the flat plane. This pattern normally is meant to be used on vertical surfaces. We also had to scale the pattern down a bit so we could see it more easily. Feel free to play around with these color list pigments, change the colors, etc. until you get a floor that you like.


Section 4.8.2.2
Using Pigment and Patterns

Let's begin texturing our sphere by using a pattern and a color map consisting of three colors. Replace the pigment block with the following.

pigment { gradient x color_map { [0.00 color Red] [0.33 color Blue] [0.66 color Yellow] [1.00 color Red] } }

Rendering this we see that it gives us an interesting pattern of vertical stripes. Try changing the gradient direction to y. The stripes are horizontal now. Try changing the gradient direction to z. The stripes are now more like concentric rings. This is because the gradient direction is directly away from the camera. Change the direction back to x and add the following change to the pigment block.

pigment { gradient x color_map { [0.00 color Red] [0.33 color Blue] [0.66 color Yellow] [1.00 color Red] } rotate -45*z // <- add this line }

The vertical bars are now slanted at a 45 degree angle. All patterns can be rotated, scaled, and translated in this manner. Let's now try some different types of patterns. One at a time, substitute the following keywords for gradient x and render to see the result: bozo , marble , agate , granite , leopard , spotted , and wood (if you like you can test all patterns listed in section "Patterns" ).

Rendering these we see that each results in a slightly different pattern. But to get really good results each type of pattern requires the use of some pattern modifiers.


Section 4.8.2.3
Using Pattern Modifiers

Let's take a look at some pattern modifiers. First, change the pattern type to bozo. Then add the following change.

pigment { bozo frequency 3 // <- add this line color_map { [0.00 color Red] [0.33 color Blue] [0.66 color Yellow] [1.00 color Red] } rotate -45*z }

The frequency modifier determines the number of times the color map repeats itself per unit of size. This change makes the bozo pattern we saw earlier have many more bands in it. Now change the pattern type to marble . When we rendered this earlier, we saw a banded pattern similar to gradient y that really did not look much like marble at all. This is because marble really is a kind of gradient and it needs another pattern modifier to look like marble. This modifier is called turbulence . Change the line frequency 3 to turbulence 1 and render again. That's better! Now let's put frequency 3 back in right after the turbulence and take another look. Even more interesting!

But wait, it gets better! Turbulence itself has some modifiers of its own. You can adjust the turbulence several ways. First, the float that follows the turbulence keyword can be any value with higher values giving you more turbulence. Second, you can use the keywords omega , lambda , and octaves to change the turbulence parameters. Let's try this now:

pigment { marble turbulence 0.5 lambda 1.5 omega 0.8 octaves 5 frequency 3 color_map { [0.00 color Red] [0.33 color Blue] [0.66 color Yellow] [1.00 color Red] } rotate 45*z }

Rendering this we see that the turbulence has changed and the pattern looks different. Go ahead and play around with the numerical values of turbulence , lambda , omega , and octaves to see what they do.


Next Section
Table Of Contents