Bill's raytracer (b-ray)
This is a very rudimentary log, with resulting images, of the ongoing progress of this project. I shall try to update it regularly.
Firstly, the basic recursive algorithm with no frills. A single light
source, three primitives to start with (sphere, plane and infinite y-axis
cylinder), simple lighting model and shadows.
Next, specular reflection. This is variable and can be combined with the
diffuse properties, as seen in the image. A perfect mirror, a half-half
mirror and finally a very slight mirror. Notice the multiple reflections
- proof that the recursion is working properly!
Next, object transformations. The image illustrates non-uniform scaling,
translation and rotation. The transformations are quite an extensive
addition to the basic structure, comprising a general matrix class as well
as a more helpful transform class.
Next, the implementation of CSG (constructive solid geometry), allowing
flexible boolean combinations of objects, including combining CSG objects
with other CSG objects. This was achieved by using a base_object class and
subclassing to define regular primitive objects or the compound CSG
objects - the beginnings of an object hierarchy. Illustrated above are the
operations union, difference and intersection for two differently-coloured
spheres. Note the differently-coloured surfaces that result!
Next, multiple coloured light sources. Not at all difficult, but does slow
down the rendering a little.
Next, specular highlights. This uses the Phong model, with an exponent
parameter that controls the tightness of the highlight, and a colour
parameter that alters how the highlight is coloured - either by the
object colour, the light source colour, or a mixture of both.
Near-future to-do list (in no particular order):
Transparency / refraction
Adaptive depth control
Antialiasing
More primitives
Procedural 3D textures (noise, checkers, gradients, wood etc)
Eventual to-do list:
Vista buffer
Area lights
Fog / atmosphere
Attenuated lights
Attenuated light within objects
Efficient triangle meshes
Parsed input language
Global illumination!
For the curious, the complete source code may be downloaded here (link also available on previous page): b-ray.zip. There is some non-functional bounding-box code in there too, and because it was developed using XCode on the Mac I expect MS Visual Studio will probably refuse to compile it...