Skip to content

From-scratch C# - BCL only

One ray tracer. Every law of physics it can prove.

Reality Sim is a single hand-written engine: a recursive Whitted-style ray tracer bolted to an SI-unit physics solver. It does not paint reflections, hit-points, or animation loops - it solves for them. Mirrors reflect because a ray genuinely bounces; a door opens because a latch joint failed under real torque; iron glows because the blackbody curve says so. Roughly 40 proof GIFs come out of the one engine, and every pixel is written with the .NET base library plus a GIF encoder and a seeded RNG. No shaders, no scene files, no assets.

~40
proof GIFs from one engine
7
self-test modules, 36 assertions
0
libraries beyond GIF + RNG
net10.0
warnings-as-errors, 0/0 build

How it renders

THE RAY TRACER

A recursive Whitted-style tracer: ray-sphere, ray-plane and ray-box intersection with outward normals, specular reflection off Vec3.Reflect, Fresnel-Schlick blending, then sRGB and an ACES filmic tonemap on the way out. A from-scratch 3x5 bitmap font labels every debug panel directly in the pixels.

THE PHYSICS

SI units throughout: impulse and lever-arm torque distributed into a joint graph with real shear and torque limits; gravity, drag, buoyancy and Magnus lift for falling bodies; sensible plus latent heat, Wien and Stefan-Boltzmann radiation, and Faraday's law for the phase and energy stations. Energy is ledgered - no free energy, and the tests assert it.

What the self-tests actually assert

Seven modules, 36 assertions, all passing - real invariants, not "looks right". A ray aimed at a sphere's mirror-image point lands back on the sphere after one bounce. Reaction forces at a kick sum exactly to the impact force, inventing no energy. A kick near the latch delivers more latch force than the identical kick near the hinge - and pushing a door against its built-in stop leaks under 10% of the force it would toward opening. sRGB round-trips; the ACES tonemap stays monotonic; facing mirrors recurse without NaN or blow-up. The material figures (pine, mild steel, soda-lime glass) are cited, order-of-magnitude values, stated as such.