imagico.de
imagico.de

imagico.de

Raytracing

previous: Raytracing and POV-Ray - an introduction to POV-Ray current: the POV-Ray scene description language Navigation

Raytracing and POV-Ray - the POV-Ray scene description language

Here you can get a rough idea how scenes can be created with the POV-Ray scene description language. Of course this can only offer a minimal introduction, to get an idea of the full set of features POV-Ray offers see the external linkPOV-Ray documentation.

Here is a fairly short example of a POV-Ray scene. It shows a classical motive of raytracing, a reflective sphere over a checkered plane. This scene contains all basic elements of a POV-Ray scene: a light source, a camera and some geometry.

the scene source code

global_settings { assumed_gamma 1.0 }

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

camera {
  location  <5.0-12.02.0>
  up z sky z
  look_at   <0.00.00.5> 
  angle 40
}

sky_sphere {
  pigment {
    gradient z
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.2 rgb <0.2,0.3,0.9>]
    }
  }
}

light_source {
  <312>*1000
  color rgb <2.21.81.5>
}   

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

plane {
  z0
  texture {
    pigment {
      checker
      color rgb 1color rgb 0
    }
  }
}

sphere {
  z*1.41
  texture {
    pigment { color rgb 1 }
    finish{
      diffuse 0.3
      ambient 0.0
      specular 0.6
      reflection 0.8
    }
  }
}

this code represents the following scene setup sphere on checkered plane scene setup
rendering this scene results in the following image sphere on checkered plane render

Note there aren't any tricks required to achieve realistic reflections and shadows, all this is automatically generated by the raytracer. Also note the sphere is really a sphere, no approximation with many planar facets and there plane is a truly infinite planar surface. All this would be much more difficult in a scanline renderer.

Obviously the real strength of POV-Ray does not become visible in such a small scene, but if we replace the single sphere in the above scene with the following code you might get an idea what a powerful tool the POV-Ray scene description language can be.

#macro Sphere(Pos, Radius)
  sphere {
    <Pos.x, Pos.y, Radius*1.3>, Radius
    texture {
      pigment { color rgb 1 }
      finish{
        diffuse 0.3
        ambient 0.0
        specular 0.6
        reflection 0.8
      }
    }
  }
#end

#local Cnt=0;
#local Seed=seed(0);

#while (Cnt<10000)
  Sphere(
    -100+<rand(Seed), rand(Seed)>*200
    0.3+pow(rand(Seed),2)*0.7
  )  
  #local Cnt=Cnt+1;
#end

sphere on checkered plane render

POV-Ray of course offers much more - a lot of different shapes, light sources etc. as well as effects like media, global illumination, photon mapping, ... And if there is something missing you are in need of you can always implement it yourself :-).