My student CGI project from 1996 that I've recently discovered in my archives.
It turns out it is the only reasonable piece of code I've ever written on C++.
The code implements pure, non-optimized ray tracing with lighting and shadows.
The code is pure C++ and is NOT using any 3-rd party libraries, graphics engines, DirectX or OpenGL.
The code is compiled using Watcom C++ with DOS/4GW to be run under DOS operating system.
The scene contains 9 fixed infinite planes, 20 moving tetrahedrons and a single moving point light source.
The animation originally contained 52 frames arranged for a looped playback, for the modern version it was modified for 208 frames for smoother playback.
Historically the program supported rendering and displaying rendered videos in two video modes:
- VGA mode
13h
: 320x200 with 256-color grayscale palette - VESA mode
10Fh
: 320x200 24-bit True Color
This resolution is currently too low and the aspect ratio is not 1:1, so for modern publishing the resolution was increased to 1600x1200.
The historical version can be found in historical
branch. It's almost "as is", but contains a pair of modern scripts to convert the original 52-frame 320x200 animation from original custom format to modern APNG (VESAFILM.png
) and MP4 (VESAFILM-H264.mp4
) formats.
The master
branch contains recently updated code that upscales the rendering to 208-frame 1600x1200 and also strips all the functionality that's difficult to observe now on modern DOS emulators like VirtualBox and DOSBox.
In particular, the following things were removed: Show
mode, on-screen rendering, 8-bit grayscale mode, custom rendering modes, RLE data format, command line options, all obsolete code. The modern version only accepts a single parameter – output file name, and all it's doing is rendering a complete 208-frame 1600x1200 scene in 24-bit color mode.
The output .sht
file can be converted to APNG (RTR.png
) format with Convert.py
and then to MP4 with Convert.cmd
, which produces two files, RTR-H264.mp4
and RTR-H265.mp4
. The latter is lossless, but is not supported everywhere. The former is lossy because of 4:2:0
color encoding, and contains visible banding, but is widely supported. Lossless 4:4:4
encoding for H.264 is unfortunately not supported by most players.