Ray Tracing, Hurts

I am enjoying this weekend quite a bit more than usual. The reason; last weekend. From about 10 PM September 13th until 4:30 PM September 17th I was working on a ray tracer for my computer graphics course.

Wikipedia has a great entry about Ray Tracing.

Ray tracing is a general technique from geometrical optics of modeling the path taken by light by following rays of light as they interact with optical surfaces… The term is also applied to mean a specific rendering algorithmic approach in 3D computer graphics, where mathematically-modelled visualisations of programmed scenes are produced using a technique which follows rays from the eyepoint outward, rather than originating at the light sources. …facilitates more advanced optical effects, such as accurate simulations of reflection and refraction…

My Ray Tracer's Output
Output of my Ray Tracer

I was honestly kinda blown away that this was our first assignment for my computer graphics course. In the end I was happy with my results, and feel that I learned a lot from the project, and had enough weight in the gradebook to warrent the time. While I worked in the lab, we averaged about four people programming there way through the project. The idea for the ray tracer is simple. Follow the ray from the view point, to each dot you want to draw, and if you intercect a object, paint it. Turns out the math to calculate the intersections and lighting was a little more than I was hoping for. While working on the project I realized I hadn’t worked with C++ in over a year, and I have never claimed to be a C++ master. I was very happy with my very object oriented and abstracted solution that allowed troubleshooting to done quickly and abstracted the topics to a level I could program a solution for. (I had many classes such as scene, camera, point, vector, ray, primitive, triangle, sphere etc. I defined operations such as dot product and cross project for vectors. Also utilitzed a virtual function in my primitive type to call the correct funtion depending on the primtive. The primitive class also allowed me to load all of the shapes into one vector or pointers to primitives. Most others were simply managing a vector per shape.)

My education has yet to teach me the name of the law that I ran into last weekend, but let me explain the characteristics. The more commited you are to a school project, the more fun offers are presented. I turned down a fishing trip, camping trip, bike race, Shane’s bowling party birthday, and Greg’s birthday taco party. Ouch.

If you haven’t noticed, the iPhone has prompted me to keep my twitter status up to date. (If you haven’t heard of it, Twitter is just quick status updates.) If you sign up you can ‘follow’ me and get updates as I post them. (Quick updates let social activity happen a little more seamless, as in; if you see me heading out to lunch or on a ride give me a call and join in.) Back to the topic on hand though, ray tracing, while working on the project I posted updates during the development of my program.

My twitter reports from the event:

  • (In the lab.) HOORAY I am submitting a perfect application and on time: “The new, better deadline for project 1 is Monday, Sep 17, 11:59… 04:23 PM September 17, 2007
  • In class. Wahoo I shadows almost done 10:34 AM September 17, 2007
  • Leaving the lab, sleep sounds good. 12:33 AM September 17, 2007
  • (In the lab.) Everyone has gone. I (think I) only lose 1 out of 100 points if I turn it in tomorrow. Must find help tomorrow. 12:08 AM September 17, 2007
  • (In the lab.) I am making progress, but I don’t know why I had to divide nspec by 2. http://flickr.com/photos/ma… 11:56 PM September 16, 2007
  • (In the lab.) 3 of the 5 of us just submitted the Ray Trace. I am not in the 3. 10:32 PM September 16, 2007
  • (In the lab.) Come on luck! Let’s normalize this triangle! 10:11 PM September 16, 2007
  • Dinner break. First time out of the lab since 11:30. 08:11 PM September 16, 2007
  • (Still in the lab.) FYI it’s B^2 blah balh blah / 2 a. NOT just a. Whoops. Triangles are set! 07:04 PM September 16, 2007
  • (Still in the Lab.) GO TIM! x y z should definitely not be int’s. Now triangles are in the right place, but wrong depth. 06:40 PM September 16, 2007
  • (Still in Lab.) Just kidding. All triangles are not in all the right places. 05:43 PM September 16, 2007
  • (Still in lab.) TRIANGLE IS IN RIGHT PLACE! Thanks Tim! 05:34 PM September 16, 2007
  • (Still in lab.) We have a triangle! It’s not in the right place though. 04:51 PM September 16, 2007
  • (Still in lab.) Troubleshooting triangles. =-/ Not showing up. 03:41 PM September 16, 2007
  • Who would of thought intersecting a triangle and a ray requires knowing all about the determinate of 3×3 matrices. Gross. 02:35 PM September 16, 2007
  • I’m trying to write a ray/triangle hit checker. Bah. 01:14 PM September 16, 2007
  • Bryan has great progress! http://www.flickr.com/photo… 01:13 PM September 16, 2007
  • Back in the lab. Progress, will you take me to be your partner for this progress? 11:43 AM September 16, 2007
  • Waiting to hop in the shower, but my Ray Tracer now does some color. (Red.) 11:04 AM September 16, 2007
  • (Still in the lab.) OMG we have silhouettes of spheres!!!! 11:44 PM September 15, 2007
  • Dinner break at Denny’s. 09:45 PM September 15, 2007
  • (Still in the lab.) Somehow pass by reference means don’t keep any value and reset to jibberish and hate Matt Matteson. 09:11 PM September 15, 2007
  • Losing hope, sanity, and happiness. Thanks homework. (Still in the lab.) 06:06 PM September 15, 2007
  • Todays Ray Tracer technique: abstract abstract abstract 12:07 PM September 15, 2007
  • Alamode is locked and my key doesn’t work. I guess back to my programming den. 09:12 PM September 14, 2007
  • Back to alamode lab after a dinner break. 09:00 PM September 14, 2007
  • In alamode lab and cranking out a ray tracer. 04:04 PM September 14, 2007
  • In Littleton, lunch with dad and helping drop the ford off. 01:35 PM September 14, 2007
  • In discrete math, thinking about how to implement my ray tracer. 11:20 AM September 14, 2007
  • DEATH BY HOMEWORK. 01:51 AM September 14, 2007

5 Responses to “Ray Tracing, Hurts”

  1. Ryan Behner Says:

    DEATH BY HOMEWORK. 01:51 AM September 14, 2007

    Seems like it was worth it. Thats some amazing stuff, personally I am fan of the triangle shadow on to the ball.

  2. Matt M Says:

    Thanks Ryan. I was real happy I got it done; gave me something for my time.

  3. David Crockett Says:

    I cannot believe you had to program that. I would go insane.

    You think that’s nuts look at what my professor did in 1971:

    http://www.graphics.cornell.edu/online/cip

    Read more here:
    http://www.graphics.cornell.edu/people/director.html

  4. Matt M Says:

    @David
    That’s awesome. I hope it was a personal project and not an assignment.

  5. Jaclyn Simpson Says:

    Maybe it’s the dislexia…but I first read this as “Tray Racing” and, I have to admit…that sounded incredibly fun…whatever it is!

Leave a Reply