Creating Photo-realistic Images and Animations

Author(s):

5. Animating the Scene

The animation given in Part I of this paper has resolution 1280x720 pixels, and is 20 seconds long at 25 frames per second. This requires generating 500 high resolution frames of the object, each with a different rotation, and stitching the frames together. This process can take a significant amount of time, even on today's powerful desktop machines. In order to speed up the turn around time, we'll create a shorter animation at lower resolution. Let's start with a 10 second video at 320x180 resolution.

We can let POV-Ray automate frame generation by using a clock variable and indicating the start and end frames in the command line. The starting frame will be number 1 and the ending frame number 250. The clock variable starts at zero and increments 1/250 each frame. So the rotate command increments the rotation about the z axis 360/250 degrees between frames. Note that only two lines (the first and the last) have changed. Save this code as in a separate folder called “anim” since it directs POV-Ray to generate 250 images. Use the command given in the first line to render the 250 frames. By removing the +P switch, there will be no pause between frames as they are generated. By including the -D switch, the frames will not be displayed on the screen as they are generated, reducing overall computation time.

Mac users of Mega-POV can set the equivalent parameters under the “Clock Settings” tab in the Preferences window.

Windows users should click on the Tools tab followed by the “Edit resolution INI file” menu item. The following text should be added at the end of the file:

[320x180 anim, AA 0.3]
Width=320
Height=180
Antialias=On
Antialias_Threshold=0.3
Output_File_Type=N
Initial_Frame=1
Final_Frame=250

Save this file and restart POV-Ray. In the drop down text window on the upper left, select the resolution “[320x180 anim, AA 0.3]”. Save it as animate.pov and render it. (Changes from dodec-05.pov above are indicated in boldface.)

// povray -D +I <strong>animate.pov</strong> +W320 +H180 <strong>Initial_Frame=1 Final_Frame=250</strong> +A

#include "golds.inc"

background{ color rgb<0.2,0.2,0.45>}

camera {
location <0, -8, 0>
up <0, 1, 0>
right <-1.78, 0, 0>
look_at <0, 0, 0>
angle 60
rotate <0, 0, 0>
}

light_source {
<100,-100,100>
color rgb<1,1,1>*2.0
}

#declare phi = (1 + sqrt(5)) / 2;
#declare c = 1 / phi;

#macro Pentagon(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5)
union{
cylinder {<x1, y1, z1>,   <x2, y2, z2>,  0.1}
sphere {<x1, y1, z1>, 0.1}
cylinder {<x2, y2, z2>,  <x3, y3, z3>, 0.1}
sphere {<x2, y2, z2>, 0.1}
cylinder { <x3, y3, z3>, <x4, y4, z4>, 0.1}
sphere {<x3, y3, z3>, 0.1}
cylinder { <x4, y4, z4>, <x5, y5, z5>, 0.1}
sphere {<x4, y4, z4>, 0.1}
cylinder { <x5, y5, z5>, <x1, y1, z1>, 0.1}
sphere {<x5, y5, z5>, 0.1}
}
#end

#declare dodecahedron =
union {
Pentagon( c, 0,  phi, -c, 0, phi,  -1,  1,  1, 0,  phi,  c,  1,  1,  1)
Pentagon(-c, 0,  phi,  c,  0, phi,  1, -1,  1, 0, -phi,  c, -1, -1,  1)
Pentagon( c, 0, -phi, -c,  0, -phi,-1, -1, -1, 0, -phi, -c,  1, -1, -1)
Pentagon(-c, 0, -phi,  c,  0, -phi, 1,  1, -1, 0,  phi, -c, -1,  1, -1)
Pentagon( 0, phi, -c,  0,  phi,  c, 1,  1,  1, phi,  c,  0,  1,  1, -1)
Pentagon( 0, phi,  c,  0,  phi, -c,-1,  1, -1,-phi,  c,  0, -1,  1,  1)
Pentagon( 0,-phi, -c,  0, -phi,  c,-1, -1,  1,-phi, -c,  0, -1, -1, -1)
Pentagon( 0,-phi,  c,  0, -phi, -c, 1, -1, -1, phi, -c,  0,  1, -1,  1)
Pentagon( phi, c,  0,  phi, -c,  0, 1, -1,  1, c,  0,   phi, 1,  1,  1)
Pentagon( phi,-c,  0,  phi,  c,  0, 1,  1, -1, c,  0,  -phi, 1, -1, -1)
Pentagon(-phi, c,  0, -phi, -c,  0,-1, -1, -1,-c,  0,  -phi,-1,  1, -1)
Pentagon(-phi,-c,  0, -phi,  c,  0,-1,  1,  1,-c,  0,   phi,-1, -1,  1)
}

object {
dodecahedron
texture { T_Gold_5A }
scale 1.25
<strong>rotate<0, 0, 360*clock> </strong>
}

After a few minutes, all the frames will have rendered. Notice that they are conveniently named animate001.png through animate250.png. If you have ImageMagick installed on your computer, you can immediately watch the animation using the command

animate *.png

To generate a movie file in one of the usual formats, I strongly recommend using the open source audio/visual manipulation tool FFMpeg. It can be downloaded at ffmpeg.org The command for generating a video in quicktime format is

ffmpeg -sameq -r 25 -i animate%03d.png animate.mov

This directs ffmpeg to generate a movie in quicktime format (animate.mov) at the same quality as the images and at a rate of 25 frames per second (click on Figure 7 to run the animation).

Figure 7 with linked animation: Animating the scene

Michael Grady (Southern Utah Univ.), "Creating Photo-realistic Images and Animations," Loci (September 2010), DOI:10.4169/loci003351