Scene files with POV-Ray

A Scene File describes the objects in a scene. The are generally the output from a modeling tool. They include a description of the model's geometery and often material and texture information as well. The are the input to a renderer. pipeline

Blender scene file format

We are going to focus on POV-Ray, since it lets us build a scene file by hand.

POV-Ray is an open-source raytracer. You can find samples of POV-Ray images here: POV-Ray images on Google

POV-Ray Installation

POV-Ray cannot be installed by system administrators. The users must each install it themselves.

POV-Ray scene files

Scene files generally contain at least four elements:

  1. Location and properties of camera
  2. Location and properties of lights
  3. Description of the modeled geometry
  4. Description of materials on the geometry

POV-Ray - Getting Started

The program starts with two samples: biscuit.pov and woodbox.pov

Here is an additional program to play with. It is the classic "Hello World" for working with a raytracer. It has a single reflective sphere hovering over a checkboard. In POV-Ray, click 'New', copy this text into the file editor, and save it as "Hello.pov".

// ------------------------------------------------------------------------
// The classic raytracer HelloWorld - a sphere hovering over a checkerboard

// (1) Camera
camera {
    location <0, 8, -15>
    look_at <0, 5, 0>
}

// (2) Lighting
global_settings { ambient_light 1.0 }

light_source {
    <10, 15, -20>              // Location
    color rgb <1.0, 1.0, 1.0>  // Color
}

light_source {
    <-5, 12, -20>              // Location
    color rgb <0.5, 0.5, 0.5>  // Color
}

// (3) Modeled Objects
plane {
    y, -1    // Plane at y == -1   

    // (4) Material of plane
    pigment {
        checker                            // Checkerboard pigment
        color rgbf <0.0, 0.0, 0.0, 0.0>    // Opaque Black 
        color rgbf <1.0, 1.0, 1.0, 0.0>	   // Opaque White
    }
    finish {
        diffuse 0.7
        phong 0.1
        reflection 0.0
    }
    scale 5   // Set size of checkers
}

sphere {
    <0, 5, 0>, 4.0       // Center, radius

    // (4) Material of sphere
    pigment { color rgbf  <0.0, 0.0, 1.0, .1>}   // Opaque blue
    finish {
        diffuse 0.65     // Increases amount object is lit from light source
        phong 0.6        // Increases specular highlights
        reflection 0.5   // Increases amount of reflected light
    }
}   
// ------------------------------------------------------------------------

POV-Ray controls

Know these:

POV-Ray Coordinate System

The usual coordinate system for POV-Ray has the positive y-axis pointing up, the positive x-axis to the right, and the positive z-axis pointing into the screen.

Best described here.

POV-Ray Camera

You can maintain the proper coordinate orientation by putting the camera at a -Z coordinate and looking towards the origin:

camera {
    location <0, 5, -10>
    look_at <0, 5, 0>
}

Place an object at the origin and render. You can adjust your camera from here to frame the image.

Full documentation of the camera controls is here.

POV-Ray Objects

Raytracers can render the polygon mesh objects that we have seen in Blender, but they work more efficiently with basic objects that can be defined mathematically: spheres, cubes, planes, cylinders, etc. POV-Ray also includes such oddities as "Surface of Revolution" and "Blob" objects.

A full listing of object types in POV-Ray is here. In general - try to model with simple primitives before going to more complex primitives.

POV-Ray Lighting

In the real world, lighting is incredibly complex. Light arrives from multiple light sources and reflects off every surface in the room. We simplify this with a Global Illumination Model, which reduces the real-world complexities to a manageable algorithm.

One of the most popular lighting models is known as the "Phong Shading Model" or the "Phong Reflection Model". It is made up of the elements below (Image courtesy of the Wikipedia Foundation, http://en.wikipedia.org/wiki/Phong_shading)

The illumination model that POV-Ray uses includes the elements in the Phong Shading Model, plus reflection:

Material properties

Objects in POV-Ray can be assigned a pigment and a finish.

A Pigment describes the color, and optionally the pattern and transparency of an object.

Pigment colors can be described with one of three commands:

The full documentation of rgb, rgbf, and rgbt is here.

More information on pigments, including the available patterns, is here.

A Finish describes the surface properties of an object. These are often the tactile properties of the material that you can feel with your fingers. For example, you can touch a surface and know whether it is glassy-smooth or rough like sandpaper, even if you cannot see the material.

The three finish properties we use most often are: diffuse, phong, and reflection. More properties are listed here.

Materials can be reused for multiple objects by using the #declare statement.

// ---------------------------------------------------------------
camera {
    location <0, 5, -10>
    look_at <0, 2, 0>
}

global_settings { ambient_light 1.0 }

light_source {
    <10, 15, -20>              // Location
    color rgb <1.0, 1.0, 1.0>  // Color
}

light_source {
    <-5, 12, -20>              // Location
    color rgb <0.5, 0.5, 0.5>  // Color
}


#declare legoRed = pigment { color rgb <1.0, 0.0, 0.0> }
#declare legoBlue = pigment { color rgb <0.0, 0.0, 1.0> }

#declare glossPlastic =
    finish {
        diffuse 0.7
        phong 0.6
        reflection 0.2
    }


#declare legocyl = cylinder { <0,-.2,0> <0,0.17,0> 0.3 }
#declare HT = 1.2;
#declare TRIM = .01;

//Build in practical units: (1x, 1y)== a 1x1 lego


#declare lego_1x1 = 
union {
  box { <0+TRIM,0+TRIM,0+TRIM> <1-TRIM, 1.2-TRIM, 1-TRIM> }
  object { legocyl translate <0.5,HT,0.5> }
}

#declare lego_2x1 =
union {
  box { <0+TRIM,0+TRIM,0+TRIM> <2-TRIM, 1.2-TRIM, 1-TRIM> }
  object { legocyl translate <0.5,HT,0.5> }
  object { legocyl translate <1.5,HT,0.5> }
}

#declare lego_4x2 =
union {
  box { <0+TRIM,0+TRIM,0+TRIM> <4-TRIM, 1.2-TRIM, 2-TRIM> }
  object { legocyl translate <0.5,HT,0.5> }
  object { legocyl translate <1.5,HT,0.5> }
  object { legocyl translate <2.5,HT,0.5> }
  object { legocyl translate <3.5,HT,0.5> }
  object { legocyl translate <0.5,HT,1.5> }
  object { legocyl translate <1.5,HT,1.5> }
  object { legocyl translate <2.5,HT,1.5> }
  object { legocyl translate <3.5,HT,1.5> }
}
    

    
object {  lego_1x1    texture { legoRed glossPlastic }  translate <-3, 0, 0>  }
object {  lego_2x1    texture { legoRed glossPlastic }  translate <-2, 0, 0>  }
object {  lego_2x1    texture { legoRed glossPlastic }  translate <-1, HT, 0> }
object {  lego_4x2    texture { legoBlue glossPlastic }  translate < 3, 0, -2> }

// ---------------------------------------------------------------