DrPetter's homepage



Raytracers



There are some projects that you keep coming back to as you get more experienced. You make something that you feel proud of, and then three years later you look at it in distaste and feel you could do so much better, so you go for a remake.
Another thing with raytracers is that there are many approaches to the general problem, so even if you make a good one you could still go back and do another using very different techniques. Raytracer or not, many times it's rewarding to revisit an old thing you made and just do it again but "do it right(er)" using the experience you gained from the first attempt along with countless other things in between.

I guess my raytracer experiments have been four-fold so far. The first one back in 2000 which wasn't too much of a raytracer at all since it only did the first raycasting step and calculated color value directly based on surface normal and light position (no reflections or shadows), but I'll include it anyway.
After that one though, I've mostly played with various kinds of monte carlo approaches of modeling light pretty directly and shooting large amounts of rays to get various effects. It's very brute force most of the time, you typically have one or several sources of random noise that affects the ray direction and have to sample over many different iterations to get an acceptable average value for each pixel. Only very recently have I considered advanced methods to optimize this by bunching up rays in the general direction(s) of light influence and similar, but I have still to make an effective implementation of it.

There has been one case of realtime raytracing which was very simple and basically just a test of what speed I could get from a normal raytracer setup with reflections and shadows, not doing any crazy tricks to gain extra speed. I think it landed at something like 40 fps for a 320x240 window with three pretty large spheres in it. No doubt one could improve this tenfold by actually doing something clever.

My main goal with most of these has been to play with the simulation of light. One idea from 2006 that I haven't attempted yet is to simulate a rainbow with reasonable "realism" (i.e. modeling drops of water and light rather than faking it with a circular gradient or some such). Will probably get back to that one at some point. Ideally it'd be a full atmospheric simulation that could provide nice sunsets and other effects too.


2000

  


2004

  


2007

   
   


--

Finally, here's a somewhat related project I did over two days in 2009 while almost participating in a game-making competition. The core technique here was raymarching into an animated implicit mathematical surface/volume using binary search. I'll paste my description and image from the competition site:

I mainly felt like goofing around this weekend, so I did. Had a vague idea for a game where you’d fly around in a cave-like world generated from audio data, but I "needed" implicit surface rendering for that, so I set out to experiment with the tech. I wasn’t too surprised to find that I didn’t have any desire to make game code after the rendering was working... I just played with different visual effects instead.

Here’s a collage of notable screenshots produced:

 

The first raw version ran at an abysmal 1 fps or so at 640×480, but after adding some bilinearly filtered variable resolution rendering based on image-space local contrast and threading it to use dual cores, I managed to kick it up to some 20-25 fps for "friendly" scenes (meaning not too much visible edge detail).

Most of the screenshots are from "bruteforce" renders though, showing no optimization artifacts. The optimized version has a mild muddy/compressed look. Putting all of this in a shader would result in much simpler code and greater performance with no visual degradation... I might have to try it some day.

You can download the (messy) source and a few builds here: drpetter-minild-ds.zip 

I also made a quick tune based on one of the drumloops given: destroyloop.mp3 

Overall it was a fun weekend. Sorry for not producing a game...





Back to all projects


Page updated on March 25   2010