I wanted to share a small project that I have created a while ago. It is a simple backwards ray tracer written in C.

hi-res

The scene is defined entirely in C code as an array of structures representing spheres.
3D polygon models can also be loaded from *.obj files. It’s still work in progress and code is a bit messy, but already produces interesting results.

obj and some spheres

Camera is controllable in real time with keyboard keys F/V/X/C/B/N for pitch/yaw/roll and Q/W for focal distance. Focal can warp through the screen producing some nice effects:

changing focal distance

Also, resolution can be tweaked (with a trade-off of less FPS).

hi-res

Here’s another, more complex polygon: hi-res

Object can be made transparent as well: hi-res

Code is available here.