szgpov

szgpov (included in the 6/20/2006 release of Aszgard as szgpov.py) brings real-time raytracing with POV-Ray into Syzygy-based virtual environments. szgpov takes information about the user's head position and handheld controller position, and inserts these coordinates into a POV-Ray scene description file (as camera and wand positions, respectively).

The scene file is concatenated as a multiline string, and saved to disk. szgpov invokes POV-Ray to render the scene (left and right eye for each wall, for a total of twelve renders per frame in the CUBE). The resulting bitmap is applied as a texture completely covering the corresponding wall.

Frame rate in szgpov

Rendering a scene in POV-Ray comprises two distinct processes, namely

These are reported in the POV-Ray statistics stream as ``parse time'' and ``render time,'' respectively. Creating an RTICA with visual interest and complexity requires us to be aware of the attendant effects on the duration of each of these—i.e., by extension, the cumulative effect on frame rate.

Parse time. For POV-Ray, scene parsing follows through all loops, macro calls, etc., meaning the time required may be disproportionate to the size of the scene description text file.

Render time. The time required to raytrace a scene depends heavily upon visual effects used. Atmospheric media, radiosity, complicated textures which include layering, reflection, refraction, and so on, all lead to additional calculations. An object whose rendering is "expensive" in this sense (i.e., CPU time) may consume more time than all the rest of a rendered image combined, even though it occupies a relatively modest portion of the space in the rendered bitmap.

Analysis of szgpov.py

szgpov.py is a Syzygy master/slave application. It imports classes from the modules PySZG, OpenGL.GL, and OpenGL.GLU.

The classes of szgpov.py are called POVApp( ), POVRenderer( ), and POVScene( ).

Data corresponding to user input from the gamepad controller is transferred from master to slaves. Each computer then creates a POV-Ray scene description file by concatenating two lists of strings:

  1. The camera description, found in POVRenderer._cameraStringList( )
  2. The core scene description, containing lights, static objects, and the user's wand. This is found in POVScene.__call__( )

The result looks something like this (fully functioning) .pov file:

camera {
location <0.000000,5.000000,0.000000>
direction <0.000000,0.000000,5.000000>
up <0.000000,10.000000,0.000000>
right <13.333000,0.000000,0.000000>}
A basic camera definition. Values are extracted in POVApp.ondraw( ) and passed to POVRenderer._cameraStringList( ).
#include "colors.inc"
#include "shapes.inc"
#include "textures.inc"
#include "glass.inc"
#include "consts.inc"
Some standard POV-Ray include files. These are similar to C's header files; they contain name-identified scene elements (colors, textures, numbers, etc.) which can then be referenced in the scene file.
light_source { <2,8,-2> color White }
light_source { <2.796411,7.354927,-2> color White }
light_source { <-4,13,-3> color Red }
Minimal definition for light sources, including location and color vectors. The location of the second light source is animated by the Lissajous function in POVScene.__init__( ). Here each color vector is an identifier, referencing colors (White and Red) established in "colors.inc".
background { color Blue } Any ray that hits no objects/media gets this color.
sphere { <0,5,3>, .5 pigment {Magenta} finish {ambient .2 diffuse .5 specular .5 }} [S]phere defined by location vector, radius (float), and texture items: pigment and finish.
box {<-.1,-.1,0>,<.1,.1,5> pigment {White} matrix <1.000000,0.000000,0.000000,0.000000, 1.000000,0.000000,0.000000,0.000000, 1.000000,2.000000,3.000000,1.000000>} The wand. A box, defined by opposite vertices (the first two vectors), minimal finish (pigment) and rotation and translation by a POV-Ray 4x3 affine matrix. The matrix values come from the handheld controller in POVScene.update( ) with the Syzygy call getMatrix(1) (which must then be converted to a POV-Ray matrix.
plane { y, 0 pigment {White} finish { ambient 0.2 diffuse 0.3 } }The "ground."

The POV-Ray scene description file generated on each computer is saved as szgpov.pov in the temporary directory base_path/syzygy/ . (E.g., in an Aszgard installation located in c:\aszgard\ , the temporary directory is c:\szg\ .) The MegaPOV command-line executable is invoked with the .pov file as input; it renders a .ppm bitmap as output. Again this is saved in the temporary directory, as szgpov.ppm .

The szgpov.ppm file is converted into an OpenGL texture, and displayed on the wall corresponding to the given computer.