Previous:Declaring Layered Textures Main Index Next:When All Else Fails: Material Maps

#### Another Layered Textures Example

To further explain how layered textures work another example is described in detail. A tablecloth is created to be used in a picnic scene. Since a simple red and white checkered cloth looks entirely too new, too flat, and too much like a tiled floor, layered textures are used to stain the cloth.

We're going to create a scene containing four boxes. The first box has that plain red and white texture we started with in our picnic scene, the second adds a layer meant to realistically fade the cloth, the third adds some wine stains, and the final box adds a few wrinkles (not another layer, but we must note when and where adding changes to the surface normal have an effect in layered textures).

We start by placing a camera, some lights, and the first box. At this stage, the texture is plain tiling, not layered. See file `layered1.pov`.

      #include "colors.inc"

      camera {

        location <0, 0, -6>

        look_at <0, 0, 0>

      }

      light_source { <-20, 30, -100> color White }

      light_source { <10, 30, -10> color White }

      light_source { <0, 30, 10> color White }

      #declare PLAIN_TEXTURE =

        // red/white check

        texture {

          pigment {

            checker

            color rgb<1.000, 0.000, 0.000>

            color rgb<1.000, 1.000, 1.000>

            scale <0.2500, 0.2500, 0.2500>

          }

        }

      // plain red/white check box

      box { <-1, -1, -1>, <1, 1, 1>

        texture {

          PLAIN_TEXTURE

        }

        translate  <-1.5, 1.2, 0>

      }

We render this scene. It is not particularly interesting, isn't it? That is why we will use some layered textures to make it more interesting.

First, we add a layer of two different, partially transparent grays. We tile them as we had tiled the red and white colors, but we add some turbulence to make the fading more realistic. We add following box to the previous scene and re-render (see file `layered2.pov`).

      #declare FADED_TEXTURE =

        // red/white check texture

        texture {

          pigment {

            checker

            color rgb<0.920, 0.000, 0.000>

            color rgb<1.000, 1.000, 1.000>

            scale <0.2500, 0.2500, 0.2500>

          }

        }

        // greys to fade red/white

        texture {

          pigment {

            checker

            color rgbf<0.632, 0.612, 0.688, 0.698>

            color rgbf<0.420, 0.459, 0.520, 0.953>

            turbulence 0.500

            scale <0.2500, 0.2500, 0.2500>

          }

        }

      // faded red/white check box

      box { <-1, -1, -1>, <1, 1, 1>

        texture {

          FADED_TEXTURE

        }

        translate  <1.5, 1.2, 0>

      }

Even though it is a subtle difference, the red and white checks no longer look quite so new.

Since there is a bottle of wine in the picnic scene, we thought it might be a nice touch to add a stain or two. While this effect can almost be achieved by placing a flattened blob on the cloth, what we really end up with is a spill effect, not a stain. Thus it is time to add another layer.

Again, we add another box to the scene we already have scripted and re-render (see file `layered3.pov`).

      #declare STAINED_TEXTURE =

        // red/white check

        texture {

          pigment {

            checker

            color rgb<0.920, 0.000, 0.000>

            color rgb<1.000, 1.000, 1.000>

            scale <0.2500, 0.2500, 0.2500>

          }

        }

        // greys to fade check

        texture {

          pigment {

            checker

            color rgbf<0.634, 0.612, 0.688, 0.698>

            color rgbf<0.421, 0.463, 0.518, 0.953>

            turbulence 0.500

            scale <0.2500, 0.2500, 0.2500>

          }

        }

        // wine stain

        texture {

          pigment {

            spotted

            color_map {

              [ 0.000  color rgb<0.483, 0.165, 0.165> ]

              [ 0.329  color rgbf<1.000, 1.000, 1.000, 1.000> ]

              [ 0.734  color rgbf<1.000, 1.000, 1.000, 1.000> ]

              [ 1.000  color rgb<0.483, 0.165, 0.165> ]

            }

            turbulence 0.500

            frequency 1.500

          }

        }

      // stained box

      box { <-1, -1, -1>, <1, 1, 1>

        texture {

          STAINED_TEXTURE

        }

        translate  <-1.5, -1.2, 0>

      }

Now there's a tablecloth texture with personality.

Another touch we want to add to the cloth are some wrinkles as if the cloth had been rumpled. This is not another texture layer, but when working with layered textures, we must keep in mind that changes to the surface normal must be included in the uppermost layer of the texture. Changes to lower layers have no effect on the final product (no matter how transparent the upper layers are).

We add this final box to the script and re-render (see file `layered4.pov`)

      #declare WRINKLED_TEXTURE =

        // red and white check

        texture {

          pigment {

            checker

            color rgb<0.920, 0.000, 0.000>

            color rgb<1.000, 1.000, 1.000>

            scale <0.2500, 0.2500, 0.2500>

          }

        }

        // greys to "fade" checks

        texture {

          pigment {

            checker

            color rgbf<0.632, 0.612, 0.688, 0.698>

            color rgbf<0.420, 0.459, 0.520, 0.953>

            turbulence 0.500

            scale <0.2500, 0.2500, 0.2500>

          }

        }

        // the wine stains

        texture {

          pigment {

            spotted

            color_map {

              [ 0.000  color rgb<0.483, 0.165, 0.165> ]

              [ 0.329  color rgbf<1.000, 1.000, 1.000, 1.000> ]

              [ 0.734  color rgbf<1.000, 1.000, 1.000, 1.000> ]

              [ 1.000  color rgb<0.483, 0.165, 0.165> ]

            }

            turbulence 0.500

            frequency 1.500

          }

          normal {

            wrinkles 5.0000

          }

        }

      // wrinkled box

      box { <-1, -1, -1>, <1, 1, 1>

        texture {

          WRINKLED_TEXTURE

        }

        translate  <1.5, -1.2, 0>

      }

Well, this may not be the tablecloth we want at any picnic we're attending, but if we compare the final box to the first, we see just how much depth, dimension, and personality is possible just by the use of creative texturing.

One final note: the comments concerning the surface normal do not hold true for finishes. If a lower layer contains a specular finish and an upper layer does not, any place where the upper layer is transparent, the specular will show through.

Previous:Declaring Layered Textures Main Index Next:When All Else Fails: Material Maps