CG2 Raytracer – Checkpoint 2 “Not What You Expected”

12.16.2011 | Computer Graphics

Checkpoint #2 – Release Name: “Not What You Expected” (http://dl.dropbox.com/u/113994/silly/gifs/J5kTJ.gif)

Remember how last week’s ray tracer was in OpenGL and GLUT? Boy, that was a mistake. Although I got the end result I was hoping for, I really shot myself in the foot for future increments. The primary reason for this was that I was attacking the problem the wrong way. Although I was able to rasterize an end result that looked visually correct, it relied on the OpenGL and GLUT calls to rasterize the end result, and I found myself having to write some janky and nefarious workarounds to make it work with GLUT that just (for lack of a better phrase) made me feel dirty.

So, on Tuesday night I decided something had to go and scrapped everything and began anew. This time, I’m taking the high road and writing everything from scratch in C++. This release has its own geometry classes (CGRay, CG3DPoint, CG3DVector, CGNormal, CGMatrix, etc.) and all that business is happening in an O-O way.

I’m happy with how it’s coming together now, and the design I’m very satisfied with. Moreover, the extra push I had to get this release working The Right Way™ will help grease the skids in the future.

Here’s a couple other improvements which I feel will help me in the future:

  • The scene is now centered at the camera at 0,0,0. Now everything can be positioned relative to the camera in absolute space, which gives me some cleaner numbers to work with when manipulating objects.
  • Ability to do supersampling.

Here’s the default output image:

Here’s a supersampled image, notice that it looks a little bit crisper (look closely):

I did not have time to add an extra object type for this release due to time constraints, but I’ll be working on that in the future, perhaps in terms of an .obj or .dae loader.

I’m also looking into deferring some of the processing to the GPU (CUDA) to increase rendering performance, and I plan to look at that over the break. I’ve installed the SDK and I’m dabbling with that now, and I hope to have some elements of GPU-accelerated rendering for the next release.

At any rate, there’s lots of cool stuff happening under the hood! Take a look:

For simplification purposes, a CGShape is an abstract class that (at this point) is either a CGSphere or CGRect.

There’s lots left to do though, so I’m going to capitalize on the break to get some extra polish done on the ray tracer. So far this scene rendered in 0.5 seconds. Not too bad, but I think I can do better!

PS: Every release I have for personal software projects is accompanied by a tagline and a silly image. This release was called “Not What You Expected” because my previous release ultimately had to be thrown out – something I most certainly didn’t expect ;)


Comments