Previous page Next page

Creating Color Patterns

We can do more than assigning a solid color to an object. We can create complex patterns in the pigment block like in 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 keyword 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 keyword slightly stirs up the pattern so the veins aren't perfect circles and the scale keyword adjusts the size of the pattern.

Most patterns are set up by default to give us 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. A scale value of one will leave an element unchanged.

Previous page Next page