here are some pics of my realtime hi-res raytracer. If you didn't think it
could be done u were wrong :)
Here's some info from the website:
subdivision subsampling: this is one of the main optimisations which
allows it to run in hi-res and realtime. This allows detail to be calculated
only where needed.
About the images:
Hardware acceleration using OpenGL: The image is divided up into small
squares, each of which is drawn as a textured quad in OpenGL, with the
colour at each vertex determined by the ray-tracer lighting calculations.
This is the other main optimisation.
Phong lighting: The lighting model is a simple ambient + diffuse +
Geometry: Objects currently included are spheres, planes, rectangles, and
Light flares: Somewhat gimmicky flares around the light sources, and
around primary reflections of the light off objects in the scene. Done with
an additive blended OpenGl quad sprite of course :). The positions of the
flares are solved analytically.
Quick approximate Sphere intersect test: This is my own invention, an
approximate test for primary ray/sphere intersection that requires only one
dot product and then a scalar compare.
Another optimisation is that not all objects need to cast shadows. In this
way the ground plane does not need to be involved in shadow checks.
Nice code: Code still uses operator overloading on my Vec3 class in most
places and uses object-orientated polymorphism on the different types of
primitives. == readable code. Of course this is slower but it shows that
high-level algorithmic optimisations are sufficient to acheive hi-res
The top image shows a simple scene with a textured plane, 2 spheres and 2
The bottom pic is the same scene rendered in line mode, showing the
As u can see from the image it is running at about 5fps on my p3-450 and
geForce2, this framerate varies greatly depending on the image complexity.
The default subdivision depth, which is used in the image above, is 3, and
as the screen is originally tessalted into a 40*40 grid, that means each
quad is about 25 / 2^3 = 3 pixels wide at maximum subdivision.
I've put up a website for this at
You can get a demo there.
I may release the src if enough people want it.
Most of the optimisation ideas that made this possible I got from a
fantastic article by some guy called Lycium. I originally read the article
(called Real Time Ray Tracing) in Hugi 23. He posted something in the
flipcode news recently as well.
You can see the article here:
Real time ray tracing
Also thanks to NateMillar for glTexFont and some tga loading code.
Shout out to all NZ coders!!!!