Introduction to Digital Image Creation and Manipulation (C 102)

UCLA Department of Design | Media Arts
Spring Quarter 2002

Machiko Kusahara

Using Povray part I: Hand-on Experience of 3D Computer Graphics

1. Introduction

PovRay is a free ray-tracing software developed and polished by the collaboration of many people. (As you know with LINUX.)
Because of that, PovRay runs practically on any machines and OS we use today.

This software is not meant for making animation although it is possible to certain extent, but features most of the techniques needed to create still images. And it is free!!
It also gives a clear idea how one can create a 3D scene using computer.

The software, instruction and templates are found from the following web site.

A detailed, very useful online manual "povuser.pdf" containing programs can be found at:

You can also find some of the works made by PovRay users on the site.

Images you see here were created by students at Kobe University using PovRay as their final works for my course. The programs were sent to me by email (they are usually not so long), and I rendered these images on my machine.

2. Using PovRay: Tutorial

Using PovRay means that you PROGRAM! (Isn't it great?)
You might be scared, but you will find the program language amazingly easy to use.
When you understand the simple rules, you can easily combine objects and effects to create your original image.

Here is a most basic sample program. Let's try.

First, open PovRay.
The program asks which file to open.
Choose "cancel", and select "new" from the "file" menu.
A program window titled "untitled.pov" opens.
Save this blank file as "test.pov" (or any file name you like).
(With PovRay, you CANNOT render an image without saving the file.
Once saved, you can open both the file and the program by clicking the file. Rendered image will be automatically saved as a pict or other file format.)

Now, copy the following program and render, by selecting "Start Rendering" from the "Render" menu.

//basic sphere

#include ""
#include ""

//set the camera
camera {
location <0, 0, -20>
look_at <0,0,0>
angle 15
//set the light source
light_source {<-3. 5, -10> color White}
//set the object and its color
object {
pigment {color Yellow}
//end of the program

Now you can "render" the scene you have created!
Did you get a sphere?

If your rendered image is rather squashed or stretched, check the "render settings" from the "edit" menu to modify the image size and ratio.
As for the image size, 320x240 might work for testing.
Save the setting and render the image again.

Later you can render a larger image when you have made a nice looking scene.
You can also change the image file format from the rendering setting menu.

3. Some Tips for Programming and Rendering

- A line starting with // means "notes". The system ignores it when computing.

- Any brackets or parentheses should be closed, i.e. should appear as pairs. When there are more than two pairs of them, they should be nested.

-Change lines as in this sample, to make the program easy to read.

-Some words (in this case, name of objects and colors) should start with capital letters, while others should be written with small letters. Don't ask me why.....

-By giving a name to certain set of functions and use it repeatedly, complex images can be produced with rather short programs. It is not only useful for multipying objects, but also amazingly useful when used with certain manipulation (such as rotating, scaling, etc.). It is called recursive function. The images above are created using such methods.

- The system is kind enough to tell you where are mistakes. You will see as you "render" the file. Hence the "debugging" starts....

- Rendering a complex scene by ray tracing requires considerable computational power and memory. By continuously rendering images, the memory can be full. If the rendering process stops without program errors, try closing PovRay to free the memory and start it again.

4. Adding and Modifying the Scene

If you have a sphere rendered safely, let's go on to modify the scene.
Numbers you find from the camera settings mean the xyz coordinates of the camera position and where the camera "looks at". X deals with the horizontal positioning, Y with vertical, Z means the depth. (If you rotate the camera position, you will be walking around on XZ plane.) Modify the numbers and render the image each time to see the difference.
For example, if you add values to Y coordinate on your camera position, you will be looking down the object.

However, PovRay can only deal with ONE program window at a time, and it AUTOMATICALLY saves the modification after rendering!!
When you create an image, be careful to SAVE your sucessful program, and CHANGE the file name BEFORE adding/modifying something new to it.
Use of some simple word processing software such as Note Pad or Simple Text can be helpful. You can use it to save or temporary keep useful lines.

Here are suggestions and samples you can use, to add or substitute elements in the scene.

When PovRay is installed, there will be "Include" folder and "Scenes" folder installed in POVRAY folder. Look for them.
"Include" folder provides with include files you can use.

Open "Scenes" folder. This is truely a wonderful source of programs and scenes that Povray users have contributed. You are invited to use these resources.@
Click any .pov file to open, and render it. If you find the image interesting, you might want to copy the program to your note pad for a later use. Among the files and folders in the "Scenes" folder, you can find interesting objects from "objects" folder including "blob" (metaball) and fractals, or a radiosity program with "radio" file, or mathematically modeled objects from the "math" folder. They are quite amazing. The "advanced" folder contatins programs you might want to integrate in your own creation.

You will see that quite complicated objects or scenes can be created by rather short programs. It is the advantage of programming.

By combining and modifying such program sequences, you can create new scenes according to your imagination.

You can also find "Template" from the menu. it will give you examples, but be careful before clicking one of them. The chosen "template" will be added to your program, at the position of the cursor.
You can "undo" if the choice or the position was wrong.

Be careful to save your program safely before trying something new.

Here are sample manipulations. Compare these sentences to the original, and find the right way to use them.

// brightness x2
light_source {<-3. 10, -10> color 2*White}

// achieve wider angle
angle 30

//change the object color
pigment { color White}

//change the light color
light_source {<-3. 10, -10> color 2*Red}

NOTICE: a wrong combination of the object color and the light color will make the object look totally black!! (A basic understanding of optics will help...)

//change the shape of the object
object {

// Change the camera position
camera {
location <5, 5, -20>

// create the ground and define the texture
object {
pigment {checker color White color Black}

// change the position of the object
translate <0,1,0>

// add a cone and change the position
object {
pigment {color White}
translate <0,3,0>

// rotate the cube

rotate 45*z
rotate 45*y

// use the wood texture

#include ""
texture {T_Wood7}

// include glass texture

#include ""

// use glass for the cone instead of using pigment
texture {T_Glass3}
interior{ I_Glass}

//change the size of the cone

scale 2

//modify the ground
#include ""
//choose brick pattern from the texture template

//add sky
#include ""
sky_sphere {S_Cloud1}

//add another light source
light_source {<0. 8, 5> color Yellow}

5. Features of PovRay

In modeling, PovRay supports methods such as CSG, b-rep(patches), metaball (blobs), lathe, sweep, and fractals.

In rendering, following features are supported.

-Lighting: point light, spot light, cylindrical light, area light, ambient light, shadowless light, highlight
-Lighting model: radiosity can be used
-Camera: focal blur
-Atmospheric effect: fog
-Texture: texture mapping, material mapping, bump mapping, pigment mapping, image mapping
-Animation is possible
-Text can be included
-Some special effects such as rainbow are included

Standard include files:
In case of glass, note that "interior" should be defined, as follows.
texture {T_Glass3}
interior{ I_Glass}

There are much more functions you can use... But don't be too ambicious from the beginning!

Start with something you can manage easily, and then experiment, using both logical thinking and your imagination.

Good luck!!