3D Visualization: POV-Ray

povray logo


General information

The Persistence Of Vision Ray-tracer creates three-dimensional, photo-realistic images using a rendering technique called ray-tracing. It reads in a text file containing information describing the objects and lighting in a scene and generates an image of that scene from the view point of a camera also described in the text file.
Ray-tracing is a rendering technique that calculates an image of a scene by simulating the way rays of light travel in the real world. The POV-Ray package includes detailed instructions on using the ray-tracer and creating scenes.
(from http://www.povray.org/documentation/)







3D Visualization: Overview



Evaluation

Installability

# # # # #

Functionality

# # # # #

Usability

# # # # #

Adaptability

# # # # #

Overall

# # # # #



POV-Ray can only be build from source, additional tools are not required. The ray-tracer can be used in multiple ways, one is for the visualization of 3D scalar fields on a structured grid via DF3 density files. The scene description language allows you to create a volume containing the density field which is pictured due to its defined properties (colour, emission, absorption, ...). The cloud-like results within the scene is seen from the cameras point of view an can additional be illuminated by light sources. It is quite demanding to get started but with some experience you can put your data on scene with high quality results.
POV-Ray runs only on the graphics hardware of a single computers. Its current version is 3.6 (in July 2010), but POV-Ray is still under active development; Linux version 3.6 has been tested.











How-to

In the following a simple introduction is given covering the installation procedure, the data file creation, the scripting in a scene description language and the necessary running commands.



How-to: Install



~> cd povrayTEMP/

~/povrayTEMP> tar -xvfz povray-3.6.tar.gz
~/povrayTEMP> cd povray-3.6/

~/povrayTEMP/povray-3.6> configure COMPILED_BY=local@domain.net --prefix=~/INSTALLDIR/povray/

~/povrayTEMP/povray-3.6> make check install



How-to: Script

This How-to is as from now on assuming you have data of a scalar field on a structured grid.



#include <fstream>
#include <algorithm>

// Define your scalars DATA[x][y][z] and dimensions NX, NY and NZ here!

file *DF3FILE;
if((DF3FILE = fopen("MYDF3FILE.df3","wb"))==NULL) return(1);

fputc( (NX >> 8) & 0xFF, DF3FILE);
fputc(  NX       & 0xFF, DF3FILE);

fputc( (NY >> 8) & 0xFF, DF3FILE);
fputc(  NY       & 0xFF, DF3FILE);

fputc( (NZ >> 8) & 0xFF, DF3FILE);
fputc(  NZ       & 0xFF, DF3FILE);

float MAXIMUM=static_cast<float>(DATA[0][0][0]),MINIMUM=static_cast<float>(DATA[0][0][0]);
for (int z=0; z<NZ; z++)
{  for (int y=0; y<NY; y++)
   {  for (int x=0; x<NX; x++)
      {  MAXIMUM=max(static_cast<float>(DATA[x][y][z]),MAXIMUM);
         MINIMUM=min(static_cast<float>(DATA[x][y][z]),MAXIMUM);
      }
   }
}

for (int z=0; z<NZ; z++)
{  for (int y=0; y<NY; y++)
   {  for (int x=0; x<NX; x++)
      {  int VALUE=static_cast<int>(2147483647*(DATA[x][y][z]-MINIMUM)/(MAXIMUM-MINIMUM));

         fputc( (VALUE >> 24) & 0xFF, DF3FILE);
         fputc( (VALUE >> 16) & 0xFF, DF3FILE);
         fputc( (VALUE >>  8) & 0xFF, DF3FILE);
         fputc(  VALUE        & 0xFF, DF3FILE);

      }
   }
}

fclose(DF3FILE);



#declare NX =  ;                                     // x-dimension
#declare NY =  ;                                     // y-dimension
#declare NZ =  ;                                     // z-dimension
#declare DIAG = <NX,NY,NZ>;

global_settings
{  ambient_light <1,1,1>
   assumed_gamma 1
}
camera
{  location <0,-7/4*NY,2/3*NZ>
   up z
   right x                                            // default: 4/3*x
   sky <0,0,1>
   look_at <0,0,0>
}
light_source
{  <2*NX,-NY,2*NZ>
   color rgb <1,1,1>
   media_interaction on
   media_attenuation on
   shadowless
}



#declare DENS = interior
                {  media
                   {  intervals 100                   // number of ray-intervals
                      ratio 0.5
                      samples 3,3                     // maximum,minimum of samples per voxel
                      method 3                        // 1, 2 or 3 (3 requires samples 3,3)
                      emission 3*<1,1,1>/100
                      absorption <1,1,1>/1000
                      scattering { 1, <0,0,0> }
                      confidence 0.999                // default: 0.9
                      variance 1/10000                // default: 1/128
                      density
                      {  density_file df3 "MYDF3FILE.df3"
                         interpolate 1
                         color_map                    // colour map with (smooth) linear transition(s)
                         {  [0.0 rgb <0.0,0.0,0.0>]   // 0.0 ~ 'black'
                            [0.2 rgb <1.0,1.0,1.0>]   // 0.2 ~ 'white'
                         }
                      }
                   }
                }

box
{  <0,0,0>, <1,1,1>
   pigment { rgbt <0,0,0,1> }
   hollow
   interior { DENS }
   scale DIAG
   translate -DIAG/2
   //rotate <0,0,360*clock>                           // rotation around z-axis
}



#declare RADIUS = 0.2;
#declare FRAME = texture
                 {  pigment { rgb <0.5,0.5,0.5> }
                 }

union
{  sphere { <00,00,00>, RADIUS texture { FRAME } }
   sphere { <NX,00,00>, RADIUS texture { FRAME } }
   sphere { <NX,NY,00>, RADIUS texture { FRAME } }
   sphere { <00,NY,00>, RADIUS texture { FRAME } }
   sphere { <00,00,NZ>, RADIUS texture { FRAME } }
   sphere { <NX,00,NZ>, RADIUS texture { FRAME } }
   sphere { <NX,NY,NZ>, RADIUS texture { FRAME } }
   sphere { <00,NY,NZ>, RADIUS texture { FRAME } }
   translate -DIAG/2
   //rotate <0,0,360*clock>                           // rotation around z-axis
}
union
{  cylinder { <00,00,00>, <NX,00,00>, RADIUS texture { FRAME } }
   cylinder { <NX,00,00>, <NX,NY,00>, RADIUS texture { FRAME } }
   cylinder { <NX,NY,00>, <00,NY,00>, RADIUS texture { FRAME } }
   cylinder { <00,NY,00>, <00,00,00>, RADIUS texture { FRAME } }
   cylinder { <00,00,00>, <00,00,NZ>, RADIUS texture { FRAME } }
   cylinder { <NX,00,00>, <NX,00,NZ>, RADIUS texture { FRAME } }
   cylinder { <NX,NY,00>, <NX,NY,NZ>, RADIUS texture { FRAME } }
   cylinder { <00,NY,00>, <00,NY,NZ>, RADIUS texture { FRAME } }
   cylinder { <00,00,NZ>, <NX,00,NZ>, RADIUS texture { FRAME } }
   cylinder { <NX,00,NZ>, <NX,NY,NZ>, RADIUS texture { FRAME } }
   cylinder { <NX,NY,NZ>, <00,NY,NZ>, RADIUS texture { FRAME } }
   cylinder { <00,NY,NZ>, <00,00,NZ>, RADIUS texture { FRAME } }
   translate -DIAG/2
   //rotate <0,0,360*clock>                           // rotation around z-axis
}



Input_File_Name=MYPOVFILE.pov                         ; input file name(s)
;Library_Path=

+W400 +H400                                           ; resolution: W(idth) times H(ight)
Display=on

Quality=9                                             ; 0 .. 11 (best), default: 9
Bounding=on
;Bounding_Threshold=25
Light_Buffer=on                                       ; (requires bounding on)
Vista_Buffer=on                                       ; (requires bounding on)
Antialias=on
Sampling_Method=1                                     ; 1 or 2 (both adaptive, 2 recursive)
Antialias_Threshold=0.1                               ;
Antialias_Depth=6                                     ; 1 .. 9 (best), default: 6
Jitter=on                                             ;
Jitter_Amount=1.0                                     ; 0.0 .. 1.0 (best)
Field_Render=off

Output_to_File=on
Output_File_Type=N                                    ; N for PNG
Output_Alpha=off
Bits_per_Color=16                                     ; 8 .. 16 for PNG
;Output_File_Name=

Initial_Frame=0
Final_Frame=36
Initial_Clock=0
Final_Clock=1



How-to: Run

~> cd MYFILES/
~/MYFILES> ~/INSTALLDIR/povray/bin/povray MYINIFILE

~/MYFILES> ~/INSTALLDIR/povray/bin/povray MYPOVFILE.pov



povray screenshot 01






Congratulations! You can now call yourself a POV-Ray user.





by Marco Selig 2010-07-19 14:28