Section 4
Beginning Tutorial

The beginning tutorial explains step by step how to use POV-Ray's scene description language to create your own scenes. The use of almost every feature of POV-Ray's language is explained in detail. You will learn basic things like placing cameras and light sources. You will also learn how to create a large variety of objects and how to assign different textures to them. The more sophisticated features like radiosity, halos, and atmospheric effects will also be explaind in detail.

The following sections explain the features in roughly the same order as they are described in the reference chapter.


Section 4.1
Your First Image

Let's create the scene file for a simple picture. Since ray-tracers thrive on spheres, that's what we'll render first.

Section 4.1.1
Understanding POV-Ray's Coordinate System

First, we have to tell POV-Ray where our camera is and where it's looking. To do this, we use 3D coordinates. The usual coordinate system for POV-Ray has the positive Y axis pointing up, the positive X axis pointing to the right, and the positive Z axis pointing into the screen as follows:


The left-handed coordinate system (the z-axis is pointing away from you).

This kind of coordinate system is called a left-handed coordinate system. If you use your left hand's fingers you can easily see why it is called left-handed. Just point your thumb in the direction of the positive x-axis, your index finger in the direction of the positive y-axis and your middle finger in the positive z-axis direction. You can only do this with your left hand. If you had used your right hand you would not have been able to point the middle finger in the correct direction.

The left hand can also be used to determine rotation directions. To do this you must perform the famous Computer Graphics Aerobics exercise. Hold up your left hand. Point your thumb in the positive direction of the axis of rotation. Your fingers will curl in the positive direction of rotation. Similarly if you point your thumb in the negative direction of the axis your fingers will curl in the negative direction of rotation.


"Computer Graphics Aerobics" to determine the rotation direction.

In the above illustration, the left hand is curling around the x-axis. The thumb points in the positive x direction and the fingers curl over in the positive rotation direction.

If you want to use a right-handed system, as some CAD systems such as AutoCAD do, the right vector in the camera specification needs to be changed. See the detailed description in "Handedness" . In a right-handed system you use your right hand for the Aerobics .

Note that there is some controversy over whether POV-Ray's method of doing a right-handed system is really proper. If you want to avoid problems we suggest you stick with the left-handed system which is not in dispute.


Section 4.1.2
Adding Standard Include Files

Using your personal favorite text editor, create a file called demo.pov . Now type in the following (the input is case sensitive, so be sure to get capital and lowercase letters correct).

#include "colors.inc" // The include files contain #include "shapes.inc" // pre-defined scene elements #include "finish.inc" #include "glass.inc" #include "metals.inc" #include "stones.inc" #include "woods.inc"

The first include statement reads in definitions for various useful colors. The second include statement reads in some useful shapes. The next read pre-defined finishes, glass, metal, stone, and wood textures. When you get a chance, have a look through them to see but a few of the many possible shapes and textures available.

You should only include files you really need in your scene. Some of the include files coming with POV-Ray are quite large and you should better save the parsing time (and memory) if you don't need them. In the following examples we will only use the colors.inc , finish.inc and stones.inc include files so you'll better remove the appropriate lines from your scene file.

You may have as many include files as needed in a scene file. Include files may themselves contain include files, but you are limited to declaring includes nested only ten levels "deep".

Filenames specified in the include statements will be searched for in the current directory first and, if not found, will then be searched for in directories specified by any +L or Library_Path options active. This would facilitate keeping all your "include" ( .inc ) files such as shapes.inc , colors.inc , and textures.inc in an "include" subdirectory, and giving an +L option on the command line to where your library of include files are.


Section 4.1.3
Adding a Camera

The camera declaration describes where and how the camera sees the scene. It gives x, y, z coordinates to indicate the position of the camera and what part of the scene it is pointing at. You describe x, y, z coordinates using a three-part vector . A vector is specified by putting three numeric values between a pair of angle brackets and separating the values with commas.

Add the following camera statement to the scene.

camera { location <0, 2, -3> look_at <0, 1, 2> }

Briefly, location <0,2,-3> places the camera up two units and back three units from the center of the ray-tracing universe which is at <0,0,0>. Remember that by default +z is into the screen and -z is back out of the screen.

Also look_at <0,1,2> rotates the camera to point at x, y, z coordinates <0,1,2>. A point 5 units in front of and 1 unit lower than the camera. The look_at point should be the center of attention of your image.


Section 4.1.4
Describing an Object

Now that the camera is set up to record the scene, let's place a yellow sphere into the scene. Add the following to your scene file:

sphere { <0, 1, 2>, 2 texture { pigment { color Yellow } } }

The first vector specifies the center of the sphere. In this example the x coordinate is zero so it is centered left and right. It is also at y=1 or 1 unit up from the origin. The z coordinate is 2 which is 5 units in front of the camera, which is at z=-3. After the center vector is a comma followed by the radius which in this case is 2 units. Since the radius is half the width of a sphere, the sphere is 4 units wide.


Section 4.1.5
Adding Texture to an Object

After we have defined the location and size of the sphere, we need to describe the appearance of the surface. The texture {... } block specifies these parameters. Texture blocks describe the color, bumpiness and finish properties of an object. In this example we will specify the color only. This is the minimum we must do. All other texture options except color will use default values.

The color you define is the way you want it to look if fully illuminated. If you were painting a picture of a sphere you would use dark shades of a color to indicate the shadowed side and bright shades on the illuminated side. However ray-tracing takes care of that for you. You pick the basic color inherent in the object and POV-Ray brightens or darkens it depending on the lighting in the scene. Because we are defining the basic color the object actually has rather than how it looks the parameter is called pigment .

Many types of color patterns are available for use in a pigment {... } statement. The keyword color specifies that the whole object is to be one solid color rather than some pattern of colors. You can use one of the color identifiers previously defined in the standard include file colors.inc .

If no standard color is available for your needs, you may define your own color by using the color keyword followed by red , green and blue keywords specifying the amount of red, green and blue to be mixed. For example a nice shade of pink can be specified by:

color red 1.0 green 0.8 blue 0.8

The values after each keyword should be in the range 0.0 to 1.0. Any of the three components not specified will default to 0. A shortcut notation may also be used. The following produces the same shade of pink:

color rgb <1.0, 0.8, 0.8>

Colors are explained in more detail in section "Specifying Colors" .


Next Section
Table Of Contents