I understand you want to create a GitHub README.md file for your MiniRT ray tracing project. Based on your codebase, I'll create a comprehensive README with diagrams that explains the concepts and architecture.
A high-performance 3D ray tracing renderer implemented in C that creates photorealistic images by simulating the physics of light. MiniRT supports multiple geometric primitives, advanced lighting models, and texture mapping.
- Ray Tracing Engine: Full implementation of ray-object intersection algorithms
- Multiple Primitives: Spheres, planes, cylinders, and cones (bonus)
- Phong Lighting Model: Ambient, diffuse, and specular lighting
- Shadow Calculation: Realistic shadow rendering
- Camera System: Configurable viewpoint and field of view
- Texture Mapping: Apply 2D images to 3D surfaces 1
- Bump Mapping: Surface detail simulation without geometric complexity 2
- Procedural Patterns: Mathematical checkerboard patterns 3
- Additional Geometry: Cone primitives for complex scenes
graph TD
subgraph "MiniRT Architecture"
A[Scene File .rt] --> B[Parser]
B --> C[World Initialization]
C --> D[Camera Setup]
C --> E[Objects Creation]
C --> F[Lighting Setup]
D --> G[Ray Generation]
E --> H[Intersection Testing]
F --> I[Shading Calculation]
G --> H
H --> I
I --> J[Pixel Color]
J --> K[Final Image]
end
The project is organized into three main components:
_Shared_files/: Common mathematical operations and geometric primitives 4_Mandatory/: Core ray tracing functionality 5_Bonus/: Extended features like textures and additional shapes 6
flowchart LR
subgraph "Rendering Process"
A[Camera] --> B[Ray Generation]
B --> C[World Intersection]
C --> D[Prepare Computing]
D --> E[Shade Hit]
E --> F[Color Output]
end
subgraph "For Each Pixel"
G[Pixel x,y] --> H[ray_for_pixel]
H --> I[world_intersection]
I --> J[prepare_computing]
J --> K[shade_hit]
K --> L[Final Color]
end
The rendering process follows these key steps:
- Ray Generation: Cast rays from camera through each pixel 7
- Intersection Testing: Find closest object hit by each ray 8
- Shading: Calculate lighting at intersection points
- Shadow Testing: Determine if points are occluded from light sources 9
Spheres use quadratic equation solving for ray intersection:
graph LR
A[Ray] --> B[Transform to Object Space]
B --> C[Quadratic Equation]
C --> D[Discriminant Check]
D --> E[Calculate t Values]
E --> F[Return Intersection]
``` [10](#1-9)
### Cylinder Creation
Cylinders are defined with position, orientation, and dimensions: [11](#1-10)
## π¨ Lighting Model
```mermaid
graph TD
subgraph "Phong Lighting Model"
A[Surface Point] --> B[Ambient Component]
A --> C[Diffuse Component]
A --> D[Specular Component]
B --> E[Final Color]
C --> E
D --> E
F[Light Source] --> C
F --> D
G[Surface Normal] --> C
G --> D
H[Eye Vector] --> D
end
The lighting system combines:
- Ambient: Global illumination
- Diffuse: Surface brightness based on light angle
- Specular: Shiny reflections for glossy materials
MiniRT/
βββ _Shared_files/ # Common utilities
β βββ sphere_intersection.c
β βββ matrix_operations_1.c
β βββ ...
βββ _Mandatory/ # Core implementation
β βββ prog_files/
β β βββ render.c
β βββ parse/
βββ _Bonus/ # Advanced features
β βββ prog_files_bonus/
β β βββ render_bonus.c
β β βββ texter_bonus.c
β βββ parse_bonus/
βββ Makefile
- GCC compiler
- MLX42 graphics library
- Make
# Build mandatory version
make
# Build bonus version with advanced features
make bonus
# Clean build files
make clean# Run with a scene file
./miniRT scenes/example.rt
# Bonus version
./miniRT_bonus scenes/textured_scene.rtCreate .rt files to define your 3D scenes:
A 0.2 255,255,255 # Ambient lighting
C -50,0,20 0,0,0 70 # Camera position, direction, FOV
L -40,0,30 0.7 255,255,255 # Light source
sp 0,0,20 20 255,0,0 # Sphere: position, radius, color
pl 0,0,0 0,1.0,0 255,255,0 # Plane: position, normal, color
cy 50.0,0.0,20.6 0,0,1.0 14.2 21.42 10,0,255 # Cylinder
4x4 matrices handle transformations: 12
The parser converts scene descriptions into internal data structures: 13
Shadows are computed by casting rays from intersection points toward light sources to check for occlusion.
The bonus version supports spherical texture mapping, converting 3D surface points to 2D texture coordinates using spherical mathematics.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 42 School for the project specifications
- Computer graphics community for ray tracing algorithms
- MLX42 library for graphics rendering
Note: This project demonstrates fundamental computer graphics concepts including 3D mathematics, lighting models, and rendering algorithms. The bonus features showcase advanced techniques like texture mapping and procedural generation commonly used in modern rendering engines.
Wiki pages you might want to explore: