Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

miniRT

A miniature ray tracer written in C that renders 3D scenes using ray casting and the Phong lighting model.

alt

Features

  • Shapes: Spheres, planes, and cylinders (with endcaps)
  • Lighting: Phong shading (ambient, diffuse, specular), multiple light sources, shadows
  • Textures: Checkerboard patterns on planes, UV mapping on spheres
  • Camera: Perspective projection with configurable position, orientation, and FOV
  • Scene format: Simple .rt text-based scene description files

Requirements

  • macOS (uses libmlx for windowed display)
  • gcc / clang

Build

make

This compiles libft, libmlx, and the main program, producing the miniRT executable.

Usage

./miniRT <scene.rt>

Press ESC to close the window.

Scene File Format

Each line in a .rt file starts with a type identifier. The following elements are required:

Identifier Description Syntax
A Ambient light A <brightness 0-1> <R,G,B>
C Camera C <x,y,z> <look-at x,y,z> <FOV>
L Point light L <x,y,z> <brightness 0-1> <R,G,B>
sp Sphere sp <x,y,z center> <diameter> <R,G,B>
pl Plane pl <x,y,z point> <normal x,y,z> <R,G,B>
cy Cylinder cy <x,y,z center> <axis x,y,z> <radius> <height> <R,G,B>

Example Scene

A 0.2 255,255,255
C 0,0,20 0,0,-1 90
L 12.5,7.5,5 1 255,255,255

sp 0,0,0 5 150,0,200
pl 0,-5,0 0,1,0 250,150,50
cy 5,0,10 0,1,0 2 8 50,250,50

Sample scenes are available in the sample/ directory.

Project Structure

minirt/
├── minirt.c          # Entry point
├── include/          # Header files
├── source/
│   ├── render/       # Rendering loop and MLX event handling
│   │   └── ray/      # Ray tracing, lighting, intersection tests
│   ├── data/         # Scene loading and parsing
│   └── error.c
├── libft/            # Custom C library
├── libmlx/           # macOS graphics library
└── sample/           # Sample .rt scene files

About

Simple ray-tracer for rendering 3D space

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages