← Projects

miniRT

September 2024

CTexturesRaytracingBump maping42
github

Probably my favorite project on the 42 Common Core, where I really discovered graphics programming. I’m currently working on the following project RT, coming soon !

Overview

A ray tracing engine built from scratch using only MiniLibx (42 educational graphic library). The renderer handles standard geomatric primitives - speheres, planes, cylinders, cones, disks - with Phong lighting, shadow casting, and reflections. A live interactive interface allows selecting and editing any scene object in real time via keyboard, with a dashboard displaying current state.

The codebase is organized around three dispatch systems - intersection, normal, computation, and UV mapping - each implemented as a linked list of typed handlers. This architecture emergede progressively during the project as primitive types multiplied: rather than growing a chain of conditionals, each object type registers its own handler at initialization.

My contributions were the overall project architecture and the entire texture pipeline. Image mapping required implementing per-primtive UV unwrapping - spherical coordinates for spheres, cylindrical projection for cylinders and cones, planar projection for planes and disks, each with its own edge cases. Bump mapping adds a layer on top: surface normals are perturbed in tangent space using height derivatives sampled from a heightmap, which required researching both the math (tangeant/bitangent frame construction, normal perturbation) and the correct sampling approach for each primitive.

Reflections are implemented via recursive ray tracing capped at depth 2 - a bonus feature, intentionally kept simple.