Intro to POV-Ray

,

This page introduces POV-Ray's graphics format.

POV-Ray is a free ray-tracing program. It reads a text file of a 3D scene description, then output a bitmap image using various techniques of lighting simulation as to create photo-realism. For more detail about POV-Ray the program, see Wikipedia: POV-Ray.

POV-Ray's home page is at: http://www.povray.org/.

POV-Ray's official documentation is at: http://www.povray.org/documentation/

Basic Operation

POV-Ray takes a input file and output a image file. For example, on the command line, type povray my_sphere.pov and it'll output a image file “my_sphere.png”. On Windows and Mac with GUI based POV-Ray, you can als use the build-in editor to write a scene file, then use menus or keyboard shortcuts to invoke commands and options to render the file. The principle is the same, specifically: POV-Ray takes a text file as input and output a image file.

To get a list of command line options, type povray -h. Here's how i use the command line for most images on this site: povray +R2 +A0.1 +J1.2 +Am2 +Q9 +H480 +W640 myScene.pov. This gives you antialiasing.

For some tips about using POV-Ray with emacs, see Emacs POV-Ray Mode.

Left-handed Coordinate System

POV-Ray uses a left-handed coordinate system. We explain below what it means.

Suppose we place a map on the table. On the map, there's East, West, and North, South. Suppose the East is the positive x-axes, and North is the positive y-axes. Now, the positive z-axes can either be pointing up from the table, or pointing down from the table. If we choose it to be pointing up, then the coordinate is right-handed coordinate system. Otherwise, it is a left-handed system.

Now, imagine the map is your computer screen. To the right is the positive x-axes. To the top is the positive y-axes. For a left-handed coordinate system, then, into the screen would be the positive z-axes. This is the model POV-Ray uses.

Basics of POV-Ray Format

simele sphere
Simple sphere on checker board.

Here's the source code.

// povray. Simple sphere on checker board.
#include "colors.inc"

background { color Cyan }

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

light_source { <3,3,3> color White}

sphere {
  <0,1,0>, 1 // position and radius
  texture { pigment { color Yellow} }
}

plane { <0,1,0> // normal vector
        , 0 // distance from origin
    pigment {
      checker color White, color Red
    }
}

Few things to note here. The #include "colors.inc" line is a way for POV-Ray to include library files. Positions or vectors has the syntax <x,y,z>. A scene typically has many geometric objects, such as the “sphere” and “camera” here. Each of these are followed by curly braces “{}”, and their position, size, orientation, surface properties, interior properties etc are specified inside.

Basic Geometric Objects

Here's a more elaborate scene description of some basic geometric objects in POV-Ray.

basic objects
Some basic POV-Ray geometric objects.
// povray
// basic objects

#include "colors.inc"

background { color Cyan }

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

light_source { <4,4,4>  color White}

sphere { <0,1,0>, 1 // position and radius
  texture {
    pigment { color Yellow }
  }
}

box {
  <2,0,0>,  // one corner
  <4,1,1>   // opposite corner
  pigment { color Green }
}

cone {
  <-2,2,0>, 1    // Center and radius of one end
  <-2,2,1>, 0.5    // Center and radius of other end
  open // remove caps
  pigment { color Pink}
}

cylinder {
  <0,0,3>,     // Center of one end
  <0,4,3>,     // Center of other end
  0.5            // Radius
  open           // Remove end caps
  texture { pigment { color Orange } }
}

torus {
  1, 0.2 // main radius and tube radius
  rotate <0,0,0> // controls orientation.
  translate <4,1,4>
  pigment { Green }
}

plane { <0,1,0> // normal vector
      , 0 // distance from origin
  pigment {
    checker color White, color Red
  }
}

2.4 Objects

Transformations

For each object, you can use the transformation commands to translate, scale, rotate the object.

torus
The green torus is at the origin. The yellow torus is rotated around the x-axes by 30°, then translated by <1,0,0>. 〔torus.pov
torus {
  1, 0.2 // main radius and tube radius. (the torus's directrix is the y-axes)
  rotate <30,0,0>      // rotate around x-axis 30°
  translate <1,0,0>  // translate by the vector (1,0,0)
}

The vectors can be multiplied by a number. For example <1,2,0>*3 is equivalent to <3,6,0>.

Also, “x” stands for <1,0,0>, “y” stands for <0,1,0>, “z” stands for <0,0,1>. So, writing 2*x is equivalent to <2,0,0>.

Also, when a single number r is given where a vector is expected, it is assumed to be <r,r,r>. So, sphere {1,4}, is equivalent to sphere {<1,1,1>,4}.

1.2.7.1 Transformations

This page is the basics of POV-Ray. There are a lot other stuff. For example, different types light (⁖ color, ambience, fading, spotlight), choice of projections (orthogonal projection, fish-eye), other geometric objects (prism, lathe, triangular mesh), textures (wood, metallic), interior (water, glass), atmospheric effects (fog). And there are also ways to do animations, specify file outputs, user defined function and variable definitions, macros etc.

blog comments powered by Disqus