Hi all,
thanks to the series on raytracing found here (http://www.devmaster.net/articles/ra...ries/part1.php), I have gotten my own Delphi version of the raytracer working



It doesn't include everything from the tutorial and it isn't optimized in anyway yet, but it works.

supported primitives
point lights
planes
spheres
triangle meshes

included functionality
diffuse lighting
specular lighting
hard shadows
reflections
lua scripting that can add lights, planes and spheres (meshes soon), and do animation.

to do
refractions
cylinder
cone
torus
capsule
2d textures
3d solid textures
soft shadows

a sample scene file is below
Code:
Yellow  = Color3f(1,1,0);
White   = Color3f(1,1,1);
LtWhite = Color3f(0.7,0.7,0.7);

NumberOfFrames = 1;
FrameNumber    = 0;
SphereY1       = -0.8;
SphereY2       = -0.5;
DeltaY         = 4 * math.sin((math.pi)*(FrameNumber/NumberOfFrames));

--define the scene
SetCamera{
    location = {0,0,-5},
    look_at  = {0,0,0}
};

NewPlane{
    name       = "ground plane",
    normal     = {0, 1, 0},
    location   = {0,-4.4,0},
    color      = {0.4, 0.3, 0.3},
    reflection = 0,
    diffuse    = 1
};

Sphere1 = NewSphere{
              name       = "big sphere",
              location   = {1, SphereY1 - DeltaY, 3},
              radius     = 2.5,
              color      = LtWhite,
              reflection = 0.6,
          };

Sphere2 = NewSphere{
              name       = "small sphere",
              location   = {-5.5,SphereY2 + DeltaY,7},
              radius     = 2,
              color      = {0.7,0.7,1},
              reflection = 1,
              diffuse    = 0.1
          };

NewLight{
    location = {0,5,5},
    color    = {0.6,0.6,0.6},
    radius   = 0.1
};
NewLight{
    location = {2,5,1},
    color    = {0.7,0.7,0.9},
    radius   = 0.1
};

--animate the scene and create an output file for each frame
while FrameNumber < NumberOfFrames do
    MoveObjectTo&#40;Sphere1,1, SphereY1 - DeltaY, 3&#41;;
    MoveObjectTo&#40;Sphere2,-5.5,SphereY2 + DeltaY,7&#41;;

    FileName = GenerateNumberedTGAFileName&#40;"testscene",FrameNumber&#41;;
    RenderScene&#40;800,600,FileName&#41;;
    FrameNumber= FrameNumber+ 1;
    DeltaY     = 4 * math.sin&#40;&#40;math.pi&#41;*&#40;FrameNumber/NumberOfFrames&#41;&#41;;
end;
For now, enjoy the .exe file (code to follow when tidied up and more complete)

http://fpc4gp2x.eonclash.com/downloads/raytracer.7z

To use, pass the full filename of the scene file to the .exe as the only parameter.

If no parameter is used, it will open up a form and generate a default scene for now.

cheers,
Paul