Skip to content
synthalorianPublic

About

CPU path tracer from scratch in C++17. Diffuse, metal, dielectric materials. No GPU, just math.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raytracer

RAYTRACER

A CPU ray tracer built from scratch. One pixel at a time.

What Is This?

A path-tracing renderer built from first principles. No OpenGL, no Vulkan, no game engines—just a framebuffer, a ray, and the rendering equation. The goal is to understand how light behaves by simulating it directly.

Why Build It?

  • Fundamentals: Every graphics engine is a layer on top of ray tracing. Start at the bottom.
  • Beautiful Results: Even simple diffuse + metal + glass produces images that feel real.
  • Reference: This project follows the structure of Peter Shirley's "Ray Tracing in One Weekend" series (books 1–3). The code is a ground-up rewrite for practice, not a copy.

Stack

  • C++17
  • CMake — build system
  • stb_image_write — PNG output (header-only)
  • PPM — raw RGB output for early debugging

How to Build

cd raytracer
mkdir build && cd build
cmake ..
cmake --build . -j
./raytracer > image.ppm
# or for PNG:
./raytracer --png output.png

Sample Output

[image_placeholder: first_sphere.png]
[image_placeholder: glass_metal_scene.png]

Output Format

Flag Description
--ppm Raw PPM, stdout (default)
--png FILE PNG via stb_image_write
--width N Image width (default 400)
--height N Image height (default 225)
--samples N Samples per pixel (default 100)
--depth N Max ray bounce depth (default 50)

License

Apache-2.0


☕ Support the Developer

If this project saved you time, solved a problem, or just made your day a little more neon, you can fuel the next one:

Buy Me A Coffee

About

CPU path tracer from scratch in C++17. Diffuse, metal, dielectric materials. No GPU, just math.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages