post Simple, heavily commented C# raytracer

Filed under Code by Iain (5:26 pm, August 25th, 2009)

Here’s a little educational recursive raytracer I wrote recently to teach a friend the fundamentals.

simpleray

Read on for full source download.

This simple C# raytracer supports spheres and planes with diffuse and specular shading and reflections. I stopped at that point to keep this as a useful tool for learning the basics.

Only trig and basic vector maths is used, with no matrices, and the maths is kept simple. Almost every line is commented, so if you like learning from source this could be for you.

Download source and binary (20Kb RAR file)

5 Comments »

  1. [...] on from my simple C# raytracer, here’s the same codebase adapted as a [...]

    Pingback by c o l d c i t y » Simple, educational C# Pathtracer — Nov 7 2009 @ 7:42 pm

  2. Thank you for your sharing your code
    Very well commented

    Regards

    Salvatore

    Comment by Salvatore — Dec 2 2010 @ 6:50 pm

  3. Thanks for sharing your source code!

    I used it as a test case for my MSIL to JavaScript compiler, and you can see the results here: http://hildr.luminance.org/JSIL/raytracer.html

    Comment by Kevin Gadd — Apr 17 2011 @ 3:47 pm

  4. Kevin, you’re very welcome — it’s great to see it being used. And that’s an AMAZING job you’ve done there!! Massively awesome :)

    Comment by Iain — Apr 27 2011 @ 7:54 pm

  5. I am that friend, for whom this was written! I did mine concurrently but in python. Here is the main render loop from mine, I hope it can be useful to someone!

    Python ray tracer main render loop: http://pastebin.com/b8yJ99GC

    Comment by Seb Clarke — May 26 2011 @ 4:22 pm

Leave a comment

ruld rurd
© 2001-2009 Iain Craig RSS Feeds Entries | Comments