prev up inhalt next


20.2.6 Public Domain Ray Tracer Povray

Der ``Persistence of Vision Ray Tracer'' (POV-Ray) ist ein urheberrechtlich geschütztes Freeware-Programm zum Berechnen einer fotorealitischen Projektion aus einer 3-dimensionalen Szenenbeschreibung auf der Grundlage der Strahlverfolgung. Seine Implementierung basiert auf DKBTrace 2.12 von David Buck & Aaron Collins. Zur Unterstützung des Anwenders gibt es einige include-Files mit vordefinierten Farben, Formen und Texturen.

Beispiel einer Szenenbeschreibung

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

camera {
       location <3, 3, -1>
       look_at  <0, 1,  2>
}
light_source { <0, 4, -3> color White}
light_source { <0, 6, -4> color White}
light_source { <6, 4, -3> color White}

plane {
       <0, 1, 0>, 0
       pigment {
               checker
                      color White
                      color Black
       }
}

sphere {
       <0, 2, 4>, 2
       texture {
               pigment {color Orange}
               normal  {bumps 0.4  scale 0.2}
               finish  {phong 1}
       }
}

box {
       <-1, 0, -0.5>,
       < 1, 2,  1.5>
       pigment {
               DMFWood4
               scale 2
       }
       rotate y*(-20)
}


Povray-Bild zur Szenenbeschreibung

Der Aufruf von povray erfolgt zweckmäßigerweise mit einem Shell-Skript, dem der Name der zu bearbeitenden Datei als einziger Parameter übergeben wird:

#!/bin/sh

povray +I$1.pov +Oscene.tga +L/usr/lib/povray3/include +W320 +H200

Die vom Ray-Tracer erstellte Statistik lautet:

scene.pov Statistics, Resolution 320 x 200
----------------------------------------------------------------------------
Pixels:           64000   Samples:           64000   Smpls/Pxl: 1.00
Rays:             64000   Saved:                 0   Max Level: 1/5
----------------------------------------------------------------------------
Ray->Shape Intersection          Tests       Succeeded  Percentage
----------------------------------------------------------------------------
Box                             238037           40342     16.95
Plane                           238037           62400     26.21
Sphere                          238037           50948     21.40
----------------------------------------------------------------------------
Calls to Noise:                  0   Calls to DNoise:          83403
----------------------------------------------------------------------------
Shadow Ray Tests:           522111   Succeeded:                24497
----------------------------------------------------------------------------
Smallest Alloc:                 12 bytes   Largest:            12308
Peak memory used:           103504 bytes
----------------------------------------------------------------------------
Time For Trace:    0 hours  0 minutes  18.0 seconds (18 seconds)
    Total Time:    0 hours  0 minutes  18.0 seconds (18 seconds)

Mit Hilfe des folgenden Shell-Skripts wird eine GIF-Datei für eine Colormap mit 256 Farben erstellt:

#!/bin/sh 

tgatoppm $1.tga | ppmquant 256 | ppmtogif > $1.gif

Die Ausgabe dabei lautet:

ppmquant: making histogram...
ppmquant: 2053 colors found
ppmquant: choosing 256 colors...
ppmquant: mapping image to new colors...
ppmtogif: computing colormap...
ppmtogif: 239 colors found


prev up inhalt next