How elbrahmi-abdessamie/minirt works
Project Type and Purpose
• miniRT is an open-source graphics tool: a simple ray tracer that parses scene descriptions, simulates light transport (ray casting & ray tracing), and outputs a 2D image.
• It is neither a full-stack web app nor a compiler; it’s a stand-alone rendering engine with optional bonus features (bump mapping, multithreading).
File Structure Analysis
• Top-level:
• Scenes/ (sample .rt scene files)
• images/ (texture bitmaps in .xpm)
• / (public headers: parser, tracer, vector, tools, etc.)
• src/ (core implementation split into minirt, parcer, tracer, vec_operations)
• bonus/ (parallel implementation of parser & tracer with bump mapping)
• libft/ (custom C standard library utilities)
• Makefile, LICENSE, README.md
• Patterns:
• Modular C code: parser module → scene graph, tracer module → ray-scene interactions, utility module → vectors/math, image I/O.
• Clear separation of concerns: parsing vs. geometry vs. ray operations vs. shading.
README Insights
• Describes rendering pipeline:
1) Ray-scene intersection
2) Shading (Phong: ambient, diffuse, specular)
3) Recursive reflection/refraction (depth limit)
4) Bonus: bump (normal) mapping
Main Components
a. Input Layer
• Scene Loader (parcer module)
• File system: Scenes/*.rt, textures in images/*.xpm
b. Core Engine
• Scene Graph: in-memory representation of objects (spheres, planes, cones, lights, camera)
• Ray Tracer:
• Ray generation (camera)
• Intersection manager (calls Geometry Module)
• Shading engine (Phong + recursive rays)
• Texture & bump mapper (bonus)
c. Output Layer
• Pixel Buffer (framebuffer)
• Image Writer (writes .bmp or displays via MLX)
d. Optional Bonus/Multi-threading Layer
• Thread manager (divides image into tiles)
• Parallel tracer instances
Relationships & Data Flow
• Scene Graph → Ray Tracer (for each pixel)
• Ray Tracer → Geometry Module → returns hit info → Shading Engine
• Shading Engine → updates Pixel Buffer
• Thread Manager (if bonus) orchestrates multiple Ray Tracer workers in parallel → merges buffers
• Pixel Buffer → Image Writer → final image output
Architectural Patterns & Principles
• Modular layering (Parser → Core Engine → Output)
• Recursive algorithm for reflection/refraction with depth cutoff
Technologies & Frameworks
• C99 / POSIX
• Custom libft (string, memory, list utilities)
• XPM for textures
• MLX (optional) or BMP writer for output
• Makefile for build automation
Summary
• Recursive nature of ray tracing, plus the optional parallelism in bonus features