Animating with POV Ray

Published on July 3, 2022 at 7:30 am by LEW

Introduction

In this post I are going to use a previous post (Sierpinski Pyramid) and create an animation from it using the POV Ray program.

Technically I will be creating several series of individual pictures that can be tied together to make an animation. POV Ray does not have the capability of producing an animation file, however it can produce a series of stills that can be combined into an animation.

There are several methods available for doing this. While this post will focus on creating the series of images, I will be using the ffmpeg program to stitch them together into a MP4 animation files. I will then use Kdenlive to combine all the animation files into one animation.

If there is any interstate, I will do a post on combining a series of images into an animation. But for this post I will focus on creating the series of images with POV Ray.

POV Ray Clock Variable

The heart of generating a series of images for an animation in POV Ray is a special variable know as clock. The clock variable is assigned an Initial_Clock value, a Final_Clock value, a Initial_Frame value, and a Final_Frame value. POV Ray will determine clock steps based on theses values.

We can use the clock value in our scene scripts. For example, in the animation I am doing, I using a clock value between 0 and 1 to move the camera to a different position in each frame.

camera {

location <0, 10, -20>

look_at <0, 5, 0>

rotate <0, 360*clock, 0>

}

Note that you need to be aware of how POV Ray handles transformations to understand the results of the above script segment. Rotation is relative to the access of origin, I n this case that is <0, 0, 0>. The location keyword translates the position of the camera away from <0, 0, 0>. However rotation still occurs around the axis of origin. Hence in this case the camera will orbit at a distance of 20 units around the Y axis while looking towards the center.

Implementing the Clock Variable

Unlike normal POV Ray renderings, a second file is required. In addition to the POV Ray scene file, you will need an INI file to set the clock variable, and render the specified number of frames. The INI file must also point to your POV Ray Scene file. To render the series of images, you run the INI file, not the POV Ray file. Below is an example I used in this animation.

; POV-Ray animation ini file

Input_File_Name = “SPAnim.pov”

Initial_Frame = 1

Final_Frame = 360

Initial_Clock = 0.0

Final_Clock = 1.0

Cyclic_Animation=on

Pause_when_Done=off

Note; make sure the extension is INI and not TXT. Windows does this sometimes when saving files with only text in them. Also the INI file uses the “;” for comments, which is different than the POV RAY scene file.

Rendering the Images

When you run the INI file with POV Ray, a series of images will be generated in the directory of the INI file. They will have the name of the INI file and the addition of a count. For example, my file is named SPAnim.ini, so the generated images will be of the form SPAnim001.png, SPAnim002.png, etc. In my case there will be 360 image files.

Putting It Together

As I stated, I used the ffmpeg program to build an MP4 out of the images. You could also make an animated PNG or Animated GIF. It will depend on the program you use to stitch them together.

I used ffmpeg because I knew I would be combining multiple animations, and in my experience MP4 just works better for that.

Conclusion

In this post I animated a POV Ray scene file using an INI file. The process may seem a little confusing at first, but it is not difficult.

While POV Ray is not the best general ray tracing program out there, it does have its strengths when it comes to rendering mathematical constructs.

Add New Comment

Your email address will not be published. Required fields are marked *