Camera

Raytracing follows the camera metaphor. That is, you have a camera for taking a picture of a scene which contains several objects. The positions of the camera and objects are represented by world coordinates. POVRAY uses a left-handed coordinate system. If the lower-left corner of your screen is considered to be the origin of a 3D coordinate system, then the x-axis is the bottom edge of your screen with its positive direction running from left to right, the y-axis is the left edge of your screen with its positive direction running from bottom up, and the z-axis is the line perpendicular to the screen with its positive direction running away from you (i.e., pointing into your monitor).

To specify a camera, you need the following:

camera {
     location       < a, b, c >
     direction      < a, b, c >
     up             < a, b, c >
     right          < a, b, c >
     look_at        < a, b, c >    // Optional
}

In the above, < a, b, c > is a vector in space giving a position; camera, location, direction, up, right and look_at are reserved keywords; and anything following // is a comment. Blank lines are allowed and treated as comments.

For your convenience, POVRAY has three predefined vectors: x, y and z. They are the unit-length vectors pointing to the positive directions of the corresponding axes. In fact, x=<1,0,0>, y=<0,1,0> and z=<0,0,1>.

You can add two vectors and subtract a vector from another. For example, <3, 4, 5> + <4, 5, 6> gives <7, 9, 11> and <3, 4, 2> - <6, 2, 9> gives <-3, 2, -7>. POVRAY also allows you to use +, -, * and / for a number and a vector.

Note that POVRAY only uses real numbers. Integers are considered as real numbers without fraction parts.

look_at

Sometimes it is difficult to get the camera orientation (i.e., up, right and direction) correct. POVRAY introduces look_at to overcome this problem. Keyword look_at simulates the way you handle your camera. You can setup your scene, the camera position, direction for "focal length", and up and right for film size (aspect ratio) without worrying about the camera orientation. Then, POVRAY rotates your camera horizontally so that the viewing line is directly above or below the point specified by look_at. Then, POVRAY rotates your camera vertically so that the viewing line passes though the look_at point.

A Few Tips

A common problem is: you think you have a fantastic scene but there is nothing on screen. If this happens, you should check to see if you have used the left-handed coordinate system. If you do, you may place the objects at wrong positions and your camera may point to an incorrect direction. Also keep in mind that the horizontal and vertical axes are the x- and y-axes, respectively, and the positive direction of the z-axis points away from you (i.e., into your monitor).

Another problem is that you get a black screen. This could be: (1) your camera is in the inside of an object, or (2) the length of vector direction is wrong. This requires some explanation.

Consider the following camera definition:

camera {
        location -10*z
        direction 3*z
        up        y
        right     4/3*x
}
The camera is at < 0, 0, -10> with a direction vector < 0, 0, 3 >. Vectors up and right are < 0, 1, 0 > and < 4/3, 0, 0 >, respectively. This camera is pointing in the positive z-direction. There is a sphere with center at the origin and radius 1.

The result is shown in the middle figure. If we change the length of vector direction from 3 to 1, 2, 3, 4 and 5, we shall get the above five figures from left to right. Thus, increasing the length of direction has the effect of moving the object closer (i.e., telephoto effect). At the same time, some surrounding objects will not be seen as the length of direction increases. Therefore, you should start with a moderate length of direction and increase it if there is too much background, or decrease it if some desired objects are not seen. Or, you might consider moving camera as well.