### Section 3.2.5
Display Types

You have already seen how to turn on graphics preview using +D1. Here are details on other variations of the +D switch. Use -D to turn the display off. If you use -D then you will probably want to add the +V switch to turn on verbose status messages so you can monitor the progress of the rendering while in progress.

The number "1" after the +D tells it what kind of video hardware to use. If you use +D alone or +D0 then POV-Ray will attempt to auto detect your hardware type. Use +D? to see a message about what type of hardware POV-Ray found.

You may also explicitly tell POV-Ray what hardware to use. The following chart lists all of the supported types.

+D0 | Auto detect (S)VGA type (Default)
+D1 | Standard VGA 320x200
+D2 | Standard VGA 360 x 480
+D3 | Tseng Labs 3000 SVGA 640x480
+D4 | Tseng Labs 4000 SVGA
+D5 | AT&T VDC600 SVGA 640x400
+D6 | Oak Technologies SVGA 640x480
+D7 | Video 7 SVGA 640x480
+D8 | Video 7 Vega (Cirrus) VGA 360x480
+D9 | Paradise SVGA 640x480
+DA | Ahead Systems Ver. A SVGA 640x480
+DB | Ahead Systems Ver. B SVGA 640x480
+DC | Chips & Technologies SVGA 640x480
+DD | ATI SGVA 640x480
+DE | Everex SVGA 640x480
+DF | Trident SVGA 640x480
+DG | VESA Standard SVGA Adapter
+DH | ATI XL display card
+DI | Diamond Computer Systems SpeedSTAR 24X

The most common type is a VESA standard card which uses +DG. VESA is a standard software interface that works on a wide variety of cards. Those cards which do not have VESA support directly built-in, generally have a video driver that you can load to provide VESA support. The program UniVBE is a high quality universal VESA driver that may work for you. It can be found at http://www.povray.org or possibly other POV-Ray sites.

The options listed above had been tested worked under earlier versions of POV-Ray but there have been many changes in the program and we cannot guarantee these all still work. If you can use VESA then do so. It has been well tested and will give you the most flexibility.

After the +D and the type, you may specify a 3rd character that specifies the palette type.

+D?3 | Use 332 palette with dithering (default and best for VGA systems). This is a fixed palette of 256 colors with each color consisting 3-bits of red data, 3-bits green and 2-bits blue.
+D?0 | Use HSV palette option for VGA display. This is a fixed palette of 256 colors where colors are matched according to hue, saturation and intensity rather than the amount of red, green and blue.
+D?G | Use fixed gray scale palette option for VGA display.
+D?H | Use HiColor option. Displays more than 32,000 colors with dithering. Supported on VESA, SpeedSTAR 24X, ATI XL HiColor and Tseng 4000 based cards with high color 15 or 16 bit options.
+D?T | For Truecolor 24 bit cards. Use 24 bit color. Supported on the Diamond SpeedSTAR 24X and cards with 24-bit VESA support only.

Here are some examples:

       +D0H Auto detect the VGA display type and display the image to the
            screen as it's being worked on. Use the 15-bit HiColor chip and
            dithering to display more than 32,000 colors on screen.
       +D4  Display to a TSENG 4000 chipset VGA using the 332 palette option.
       +D4H Display to a TSENG 4000 chipset VGA using the HiColor option.
       +DG0 Display to a VESA VGA adapter and use the HSV palette option.
       +DG3 Display to a VESA VGA adapter and use the 332 palette option.
       +DGH Display to a VESA VGA adapter and use the HiColor option for
            over 32,000 colors.
       +DGT Display to a VESA VGA adapter and use the TrueColor option for
            over 16 million colors.

Note that your VESA BIOS must support these options in order for you to use them. Some cards may support HiColor and/or TrueColor at the hardware level but not through their VESA BIOS.

### Section 4
Beginning Tutorial

The beginning tutorial explains step by step how to use POV-Ray's scene description language to create own scenes. The use of almost every feature of POV-Ray's language is explained in detail. We will learn basic things like placing cameras and light sources. We 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 be explained in detail.

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

### Section 4.1
Our First Image

We will create the scene file for a simple picture. Since ray-tracers thrive on spheres, that is what we will 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 is 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).

This kind of coordinate system is called a left-handed coordinate system. If we use our left hand's fingers we can easily see why it is called left-handed. We just point our thumb in the direction of the positive x-axis, the index finger in the direction of the positive y-axis and the middle finger in the positive z-axis direction. We can only do this with our left hand. If we had used our right hand we 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 we must perform the famous Computer Graphics Aerobics exercise. We hold up our left hand and point our thumb in the positive direction of the axis of rotation. Our fingers will curl in the positive direction of rotation. Similarly if we point our thumb in the negative direction of the axis our 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 we want to use a right-handed system, as some CAD systems and modellers do, the right vector in the camera specification needs to be changed. See the detailed description in "Handedness". In a right-handed system we use our right hand for the Aerobics.

There is some controversy over whether POV-Ray's method of doing a right-handed system is really proper. To avoid problems we stick with the left-handed system which is not in dispute.

### Section 4.1.2
Adding Standard Include Files

Using our personal favorite text editor, we create a file called demo.pov. We then type in the following text. The input is case sensitive, so we have to 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. It is a good idea to have a look through them to see but a few of the many possible shapes and textures available.

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

We may have as many include files as needed in a scene file. Include files may themselves contain include files, but we 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 our "include" (.inc) files such as shapes.inc, colors.inc and textures.inc in an "include" subdirectory, and giving an +L switch on the command line to where our 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- and z-coordinates to indicate the position of the camera and what part of the scene it is pointing at. We describe the 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.

We 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>. 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 the 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 our 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. We add the following to our 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 one unit up from the origin. The z coordinate is 2 which is five 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 two units. Since the radius is half the width of a sphere, the sphere is four 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 we define is the way we want an object to look if fully illuminated. If we were painting a picture of a sphere we 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. We 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. We can use one of the color identifiers previously defined in the standard include file colors.inc.

If no standard color is available for our needs, we may define our 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 from 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".

### Section 4.1.6
Defining a Light Source

One more detail is needed for our scene. We need a light source. Until we create one, there is no light in this virtual world. Thus we add the line

      light_source { <2, 4, -3> color White}

to the scene file to get our first complete POV-Ray scene file as shown below.

      #include "colors.inc"

      background { color Cyan }

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

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

      light_source { <2, 4, -3> color White}

The vector in the light_source statement specifies the location of the light as two units to our right, four units above the origin and three units back from the origin. The light source is invisible, it only casts light, so no texture is needed.

That's it! We close the file and render a small picture of it using the command

      povray +w160 +h120 +p +x +d0 -v -idemo.pov

If our computer does not use the command line, we have to read the platform specific docs for the correct command to render the scene.

We may also set any other command line options we like. The scene is written to the image file demo.tga (or some suffix other than .tga if our computer uses a different default file format).

The scene we just traced isn't quite state of the art but we will have to start with the basics before we soon get to much more fascinating features and scenes.

### Section 4.2
Using the Camera

### Section 4.2.1
Using Focal Blur

Let's construct a simple scene to illustrate the use of focal blur. For this example we will use a pink sphere, a green box and a blue cylinder with the sphere placed in the foreground, the box in the center and the cylinder in the background. A checkered floor for perspective and a couple of light sources will complete the scene.

We create a new file called focaldem.pov and enter the following text

      #include "colors.inc"
      #include "shapes.inc"
      #include "textures.inc"

      #version 3.0

      global_settings {
        assumed_gamma 2.2 // for most PC monitors
        max_trace_level 5
      }

      sphere { <1, 0, -6>, 0.5
        finish {
          ambient 0.1
          diffuse 0.6
        }
        pigment { NeonPink }
      }

      box { <-1, -1, -1>, < 1,  1,  1>
        rotate <0, -20, 0>
        finish {
          ambient 0.1
          diffuse 0.6
        }
        pigment { Green }
      }

      cylinder { <-6, 6, 30>, <-6, -1, 30>, 3
        finish {
          ambient 0.1
          diffuse 0.6
        }
        pigment {NeonBlue}
      }

      plane { y, -1.0
        pigment {
          checker color Gray65 color Gray30
        }
      }

      light_source { <5, 30, -30> color White }

      light_source { <-5, 30, -30> color White }

Now we can proceed to place our focal blur camera to an appropriate viewing position. Straight back from our three objects will yield a nice view. Adjusting the focal point will move the point of focus anywhere in the scene. We just add the following lines to the file:

      camera {
        location <0.0, 1.0, -10.0>
        look_at  <0.0, 1.0,  0.0>

      //  focal_point <-6, 1, 30>    // blue cylinder in focus
      //  focal_point < 0, 1,  0>    // green box in focus
        focal_point < 1, 1, -6>    // pink sphere in focus

        aperture 0.4     // a nice compromise
      //  aperture 0.05    // almost everything is in focus
      //  aperture 1.5     // much blurring

      //  blur_samples 4       // fewer samples, faster to render
        blur_samples 20      // more samples, higher quality image
      }

The focal point is simply the point at which the focus of the camera is at its sharpest. We position this point in our scene and assign a value to the aperture to adjust how close or how far away we want the focal blur to occur from the focused area.

The aperture setting can be considered an area of focus. Opening up the aperture has the effect of making the area of focus smaller while giving the aperture a smaller value makes the area of focus larger. This is how we control where focal blur begins to occur around the focal point.

The blur samples setting determines how many rays are used to sample each pixel. Basically, the more rays that are used the higher the quality of the resultant image, but consequently the longer it takes to render. Each scene is different so we have to experiment. This tutorial has examples of 4 and 20 samples but we can use more for high resolution images. We should not use more samples than is necessary to achieve the desired quality - more samples take more time to render. The confidence and variance settings are covered in section "Focal Blur".

We experiment with the focal point, aperture, and blur sample settings. The scene has lines with other values that we can try by commenting out the default line with double slash marks and un-commenting the line we wish to try out. We make only one change at a time to see the effect on the scene.

Two final points when tracing a scene using a focal blur camera. We needn't specify anti-aliasing (the \Clo{+A} switch) because the focal blur code uses its one sampling method that automatically takes care of anti-aliasing. Focal blur can only be used with the perspective camera.

Next Section
Table Of Contents