A real-time CPU ray tracer that renders to a text console.
I have written this code a few times, and this is probably the most complete it has ever gotten.
On Behest of the reddit comments I implemented a renderer that uses PInvoke to directly write into the terminal memory buffer, and a renderer that uses ANSI color codes.
Example video of the ANSITerminalRenderer providing a MASSIVE speedup, the PInvoke is about the same speed but plays less nicely with the debug text printing.
Higher Quality version here: [Assets/RTConsole.mp4]
Raytracer_720p_small.mp4
You need to change a line in Program.cs to activate it but there is a video reader mode which allows reading cameras and arbitrary video files
2025-08-20.01-50-31.mp4
High Res
Low Res
- Arrow keys: look
- WASD / Q / E: move (hold Shift to go faster)
- I / U: next / previous scene
- Esc: quit
Press I/U to cycle. The table is built in RaytraceEntity.BuildSceneTable() and includes:
- Test/Demo scenes
- Cornell Box
- Mirror spheres on a checker plane
- Cylinders, disks, triangles, and boxes showcase
- Volume grid test and “minecraft-like” voxel scene
- Mesh scenes: Bunny, Teapot, Cow, Dragon Each scene provides default camera pose and FOV; switching resets TAA history and rebuilds the BVH.
