This project has been created as part of the 42 curriculum by kinamura, stakada.
miniRT is a ray tracing engine written in C that renders 3D scenes using the MiniLibX graphics library. It implements ray tracing algorithms to generate computer-generated images with geometric objects, lighting, and shadows.
- Ray tracing with spheres, planes, and cylinders
- Ambient and diffuse lighting with hard shadows
- Configurable camera with field of view control
- Scene description parser for
.rtfiles - RGB color system and smooth window management
- Operating System: macOS or Linux
- Compiler:
gccorclangwith C99 standard support - Make: GNU Make
- Libraries: MiniLibX (included in repository)
- X11 (Linux only): Required for MiniLibX on Linux systems
# Compile the project
cd miniRT
make
# The executable will be created at bin/miniRTAvailable Make targets:
makeormake all: Compile the projectmake clean: Remove object filesmake fclean: Remove object files and executablemake re: Recompile the entire project
Run the program with a scene file:
./bin/miniRT scenes/valid/<filename>.rtScene files (.rt extension) define the 3D environment. Each element is defined on a separate line with specific parameters:
Ambient Lighting (required, one only):
A <ratio> <R,G,B>
ratio: Ambient lighting ratio [0.0, 1.0]R,G,B: Color values [0-255]
Camera (required, one only):
C <x,y,z> <nx,ny,nz> <fov>
x,y,z: Camera position coordinatesnx,ny,nz: Normalized orientation vector [-1.0, 1.0]fov: Field of view [0, 180]
Light (required, one only):
L <x,y,z> <brightness> <R,G,B>
x,y,z: Light position coordinatesbrightness: Light brightness ratio [0.0, 1.0]R,G,B: Color values [0-255] (bonus feature)
Sphere:
sp <x,y,z> <diameter> <R,G,B>
Plane:
pl <x,y,z> <nx,ny,nz> <R,G,B>
Cylinder:
cy <x,y,z> <nx,ny,nz> <diameter> <height> <R,G,B>
- ESC: Close window and exit program
- Close button (×): Close window and exit program
- Ray Tracing in One Weekend by Peter Shirley - Comprehensive introduction to ray tracing concepts
- Understanding Complex Concepts: Clarifying ray tracing mathematics, vector operations, and lighting algorithms through explanations and examples
- Debugging Assistance: Identifying potential edge cases, suggesting debugging approaches for intersection calculations
- Documentation: Drafting initial code comments and README structure
- Code Review: Getting suggestions for potential improvements and optimizations
Important Note: All AI-generated content was reviewed, tested, and discussed with peers.
miniRT/
├── bin/ # Compiled executable
├── includes/ # Header files
│ ├── miniRT.h # Main header
│ ├── config.h # Configuration constants
│ ├── ctx.h # Context structures
│ ├── errors.h # Error handling
│ ├── parsing.h # Parser functions
│ └── render.h # Rendering functions
├── libft/ # Custom C library
├── objs/ # Object files
├── scenes/ # Scene description files
│ ├── valid/ # Valid test scenes
│ └── error/ # Invalid scenes for testing
├── srcs/ # Source files
│ ├── parsing/ # Scene file parsing
│ ├── render/ # Ray tracing engine
│ ├── transform/ # Coordinate transformations
│ └── utils/ # Helper functions
├── Makefile # Build configuration
└── README.md # This file
This is a student project created as part of the 42 school curriculum. Feel free to reference it for learning purposes, but please do not copy it directly for your own 42 projects.
- 42 Tokyo for providing the curriculum and learning environment
- The MiniLibX library developers
- The ray tracing community for extensive documentation and resources