Previous:Clock Dependant Variables And Multi-Stage Animations Main Index Next:Do Not Use Jitter Or Crand

#### The Phase Keyword

There is another keyword we should know for purposes of animations: the `phase` keyword. The phase keyword can be used on many texture elements, especially those that can take a color, pigment, normal or texture map. Remember the form that these maps take. For example:

      color_map {

        [0.00 White ]

        [0.25 Blue ]

        [0.76 Green ]

        [1.00 Red ]

      }

The floating point value to the left inside each set of brackets helps POV-Ray to map the color values to various areas of the object being textured. Notice that the map runs cleanly from 0.0 to 1.0?

Phase causes the color values to become shifted along the map by a floating point value which follows the keyword `phase`. Now, if we are using a normalized clock value already anyhow, we can make the variable clock the floating point value associated with phase, and the pattern will smoothly shift over the course of the animation. Let's look at a common example using a gradient normal pattern

      #include "colors.inc"

      #include "textures.inc"

      #background { rgb<0.8, 0.8, 0.8> }

      camera {

        location <1.5, 1, -30>

        look_at <0, 1, 0>

        angle 10

      }

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

      // flag

      polygon { 5, <0, 0>, <0, 1>, <1, 1>, <1, 0>, <0, 0>

        pigment { Blue }

        normal {

          gradient x

          phase clock

          scale <0.2, 1, 1>

          sine_wave

        }

        scale <3, 2, 1>

        translate <-1.5, 0, 0>

      }

      // flagpole

      cylinder { <-1.5, -4, 0>, <-1.5, 2.25, 0>, 0.05

        texture { Silver_Metal }

      }

      // polecap

      sphere { <-1.5, 2.25, 0>, 0.1

        texture { Silver_Metal }

      }

Now, here we've created a simple blue flag with a gradient normal pattern on it. We've forced the gradient to use a sine-wave type wave so that it looks like the flag is rolling back and forth as though flapping in a breeze. But the real magic here is that phase keyword. It's been set to take the clock variable as a floating point value which, as the clock increments slowly toward 1.0, will cause the crests and troughs of the flag's wave to shift along the x-axis. Effectively, when we animate the frames created by this code, it will look like the flag is actually rippling in the wind.

This is only one, simple example of how a clock dependant phase shift can create interesting animation effects. Trying phase will all sorts of texture patterns, and it is amazing the range of animation effects we can create simply by phase alone, without ever actually moving the object.

Previous:Clock Dependant Variables And Multi-Stage Animations Main Index Next:Do Not Use Jitter Or Crand