Experiments in Ray-Tracing, Part 1

This is a very old article, included for historical interest only!

I was bored the other evening, so I decided to knock together a little ray-tracing application in C#. I’ve always wondered a couple of things about ray-tracing:

  • How fast can you make a ray-tracer?
  • How easy is it to code a tracer that produces realistic images?

(You might think it’s a little odd to be trying to write a fast ray-tracer in C# - but realistically, a C++/assembler implementation would only be a few times faster – so I can get an idea of how fast it could potentially be, while keeping the fast development environment of .NET).

I’m going to write a series of articles about how I’ve coded it so far, but to answer those two questions first:

  • I can render approximately 200,000 anti-aliased, ray-traced pixels per second in pure C#, and,
  • Writing a ‘standard’ ray-tracer really is easy… writing an optimized one is trickier… and writing a photo-realistic one is going to take me more time.

Here’s where I’ll be going in the first set of articles:

Example ray-traced image

(I’ve doubled the size of the pixels so you can get a better idea of what’s being produced).

Yes – it’s shiny balls on a chessboard. There’s a reason that’s the first image everyone produces in a ray-tracer – but I’ll get onto that later.

Written on July 11, 2008. Category: Ray Tracing