The Online POV-Ray Tutorial

Camera

The following topics are covered in this section. The following predominantly blue scene will be used to demonstrate the effects of the various camera modifiers.


Camera

The camera defines what you exactly you see when you render an image. The camera is probably the sinlge most important element of a scene. Without a camera, there is no image (although it may just be all black without a few other things). There can only be one camera per scene. The POV-Ray camera is a very simple type of camera. It is not a "lens" camera, and consequently everything in the scene is always in focus. All you usually need to worry about with a camera is where it is and where it's pointing. The default settings usually take care of the rest. The general form for declaring a camera is something like this

camera {
   location <loc>
   sky <sky vector>
   up <up vector>
   right <right vector>
   direction <direction vector>
   look_at <target>
/* translations, rotations, and scales */
}

When declaring a camera, components that appear should do so in this order. This is because some later components modify previous ones, and putting them in the wrong order may result in your camera not doing exactly what you expect. Actually, the only really important ordering is that "look_at" should appear after "direction" if they are both present.

Location is pretty self evident; it tells POV-Ray where in space to locate the camera. It takes an <x, y, z> vector of the location.

Sky is used to tell the camera which way is up. Modifying this value can be used to roll the camera around its central axis.

Up, right, and direction are used to modify the field of view and aspect ratio of the image.

Direction and look_at are used to point the camera at a specific point in the scene. Direction is more typically used with up and right to define field of view then to position the camera, though.

Most of the time, you'll only need to use "location" and "look_at" to define your camera. The other specifiers can be used for fine tuning a scene and producing special effects.

After the camera is declared, it can be transformed like any other object. Any transformation applied to object modify the location of the camera and (potentially) the direction it's pointing.


Direction

The direction vector is primarily used in conjunction with up and right to define the field of view. It can also be used to implement a telephoto lens or, less commonly, to orient the camera (but this is more commonly done with look_at. The default value of direction is <0, 0, 1>. Increasing the magnitude of the direction vector "stretches" the viewing pyramid and creates a telephoto sort of effect. Decreasing the magnitude of the direction vector "compresses" the viewing pyramid and gives the effect of a wide-angle camera. Here are some sample images with different direction vectors. The first uses "direction <0, 0, 0.5>", the second "direction <0, 0, 1>", the third "direction <0, 0, 2>", and the fourth "direction <0, 0, 4>".

The direction vector should always be perpendicular to the up and right vectors.

For more information on declaring cameras, see the camera section.


Location

The location keyword tells POV-Ray where to position the camera. This parameter must always be specified. It takes an <x, y, z> vector which tells the location of the camera. Note that if you have specified an look_at point, moving the location will also rotate the camera (maybe), while if you instead specify a direction, changing the location will not modify the rotation of the camera.

For more information on declaring cameras, see the camera section.


Look At

The look_at parameter controls the orientation of the camera. It is by far the easiest way to get the camera to point at the thing you want it to point at. You can also specify a camera direction with the direction vector, but this becomes tedious when you're not looking directly along an axis. Also, when you specify a look_at point, you can move the camera around and modify the parameters to your heart's delight, and the POV-Ray will rotate the camera around so it still points at the same place. Note that if look_at is specified with direction, the look_at specifier should appear after the location specifier. This is because the direction vector resets the direction that camera points. Anyway, here's our sample scene with various look_at points.

One thing to keep in mind when using look_at is that the location and look_at points should never be set so that the camera is looking directly down (parallel to the y-axis). If you want an "overhead" view, either offset the camera some small amount in the x or z direction, or rotate the entire scene so it just appears like you're looking straight down (but are actually looking along, say, the z-axis).

For more information on declaring cameras, see the camera section.


Right

The right vector controls the width of the view. It is used in conjunction with the up vector to define the aspect ratio of the image. Aspect ratios are covered in more depth in the up section. The angular width of the viewing pyramid can be found with the following equation. The vertical bars mean the magnitude (length) of the named vector.

width = 2 * atan(|right| / |direction|)

This diagram may help make the relationship of the right and direction vectors more clear. This is a diagram of the viewing pyramid as it would look from above.

Increasing the magnitude of the right vector will make the viewing pyramid wider, and consequently make the image appear "squished" in the left-right direction. Conversely, decreasing the magnitude of the right vector will make the viewing pyramid thinner, and make the image appear "stretched" in the left-right direction. Making the value of the right vector negative will reverse the image left to right. A right vector with a magnitude of zero is bad.

The first image below was rendered with "right <4/3, 0, 0>", the second with "right <1, 0, 0>", and the third also with "right <1, 0, 0>" but rendered at 120x120 instead of 160x120.

For more information on declaring cameras, see the camera section.


Sky

The vector tells the camera which way is up. This is not to be confused with the up vector which defines the aspect ratio. The default sky vector is <0, 1, 0>. By modifiying this value, you can roll the camera around its central axis. The sky vector, if specified, must appear before the look_at point is specified. This vector has no effect if look_at is not specified. The first image below is rendered with "sky <2, 1, 0>", and the second with "sky <0, -1, 0>".

For more information on declaring cameras, see the camera section.


Up

The up vector is used to define the height of the viewing pyramid and, in conjunction with the right vector, the aspect ratio of the image. The combination of the up and direction vectors defines the angular height of the viewing pyramid. This can be found with the following equation. The vertical bars mean to take the magnitude (length) of the named vector.

height = 2 * atan(|up| / |direction|)

This diagram may clarify the relationship between the up and direction vectors. This is a diagram of the viewing pyramid as it would look from the side.

The default value of the up vector is "up <0, 1, 0>". This, together with the value "right <4/3, 0, 0>" (also default) defines the aspect ratio of the rendered image to be (4/3) / (1) = 4/3. This is the standard aspect ratio for most computer screens. Resolutions like 800x600, 640x480, and 1024x768 all have 4/3 aspect ratios. 320x200 also has a 4/3 aspect ratio, even though it would seem like it should be 8/5. This is because this resolution does not use square pixels. To prevent your image from looking distorted, it's a good idea to make the camera's aspect ratio the same as the image's aspect ratio.

Modifying the value of the up vector independently of the right and direction has the same stretch/squish effect as with the right vector, only this stretch/squish is in the vertical direction.


Reference Index Top of Document Beginning of the Tutorial

The Online POV-Ray Tutorial © 1996 The Online POV-Ray Tutorial ThinkQuest Team