Rend - A Managed Ray Tracing Engine

Rend is something as rare as a managed ray tracer, something you don't see every day, discounting the more simple implementations available on various programming sites (or the more exotic, such as a ray tracer implemented in a single LINQ query!). It is not due to the whimsicality of chance that there are so few ray tracers in C# or other .NET languages - it is the same reason that computer games are written almost solely in C++ - performance.

Programs written in .NET languages are not slow by any means, but they do come up a bit short for the massive task of ray tracing which can bring any computer to its knees. C++ relies on lots of micro optimizations to achieve optimal performance and many of them are simply not available in .NET such as the use of SIMD instructions. For the same reasons, I decided to stay away from real-time ray tracing and focus on creating the most realistic and beautiful images.

Given the performance of Rend and the abundance of faster and more powerful alternatives, I'm not sure if I will find any useful application for the engine, but as long as it remains as rewarding to work on as it has been so far I'll keep expending on it's features (though it seems the work backlog grows quite a bit faster than what I can keep up with). My current goals are to have an engine with which you can create small animated video clips in a reasonably approachable way. It is already capable of loading an IronPython script to produce still images and video, but available effects are lacking and the usability of the engine needs a bit of polishing as well. Once these issues have been ironed out I will upload Rend and I hope you will return and check it out.

Main Features

To give you an idea of the capabilities of Rend, here is a list of the primary features and effects it supports:

  • Ambient, diffuse and specular coloring of objects.
  • Reflection and refraction of light to create glass-like objects.
  • Hard shadows (also soft shadows but with sub-optimal quality).
  • Dynamic anti aliasing using edge detection.
  • Texture mapping with bilinear filtering.
  • Supports spheres, boxes, planes and triangle primitives.
  • Kd-tree for spatial division of objects.
  • A plugin model with many extension points.
  • Imports 3D models from .x and .obj files (currently not very robust implementations).
  • Camera animation and video generation.
  • An IronPython scripting interface.
  • Post-processing effects such as color inversion, grayscaling, gaussian blur, sharpening, edge detection etc.

Showcase

Here is a little preview of what the engine can do so far:

 

A mixed collection of objects A mixed collection of objects including a textured moon.

Glass sphere A glass sphere demonstrates the refraction of light.

The classic 3D teapot The classic Utah Teapot.

The classic 3D teapot in glass The Utah Teapot made from glass.

Space Flight A flight of space ships leaving Earth - model courtesy of XNAfusion.com.

Rendering errors

Sometimes things go wrong, such as when I first tried to implement spatial division with Kd-Trees (This is supposed to be the same scene as the first image with some additional spheres).

Resources

Rend started out as a port of the principles and code described in a series of C++ tutorials over at DevMaster.net.

I have found additional inspiration in another excellent tutorial series by the Codermind team.