Anti-Aliased Raytracing

I added anti-aliasing to the rendering of the ray tracer. At first I tried regular sampling which is breaking a pixel down into smaller sub-pixels and shooting rays through the center of those pixels and averaging the result. This was better than nothing but still created some artifacts when rendering. The next trial was random sampling to replace aliasing with noise, but the samples can become clumped together and look unnatural. The method that I have settled on for now is jittered sampling which consists of breaking the target pixel down into sub-pixels and shooting rays at a random position through the sub-pixels so that each sub-pixels has at least one ray shot through it. Changing the amount of samples per pixel reduces the aliasing effect.

This type of anti-aliasing is hard coded into the display function. In the next week I am going to abstract this process away so that different methods of anti-aliasing can be used without changing lots of code.

The image that is attached is rendered with jittered sampling with 64 samples per pixel.

Antialiased circles


Since I got my new laptop, I have been working on a personal project creating a simple, easily extendable raytracer.

I have got it working so far, but at the moment it doesn’t do too much. I have sphere and plane rendering working and saving to TGA images. The whole thing should look a lot better once I add anti-aliasing, shadows, reflections, refractions, shading and different types of objects. For now here is a picture showing what it can do at the moment. (Currently only orthogonal projection is supported). Not bad for a day and a half of work!

Two intersecting spheres

Doesn’t really look too great at the moment because the raytracer doesn’t support shading or perspective projection, but these should be added in the next couple of days.

I am really excited to be writing a raytracer, but I am going to have to force myself to have some time off at some point (because a ray tracer is never done!) to work on some other projects. This project has only been tested on OSX Snow Leopard but should be cross platform if the bitmap creation libraries are recompiled for a different platform. I may post code later at some point, but the image saving code is not mine and I will have to check the license conditions.

More updates to come soon.