Project

Raytracing on the CPU

CPU based Raytracer for voxels in C++

Raytracing on the CPU Preview

🎓 About the Block

This project was part of my university curriculum, where the goal was to implement a raytracing engine in 8 weeks using the provided template, focusing on voxel-based rendering. I designed and developed the core raytracing algorithm, which runs entirely on the CPU, allowing it to simulate lighting effects like shadows, reflections, and refractions.

The project served as my introduction into graphics programming.

📂 Source Code & Template

The game is based on a template I received during the block, which you can find here on GitHub.

🛠️ Technologies Used

  • C++: Developed core game logic and the raytracing algorithm.
  • GLFW: Managed graphics rendering, window handling, and input events to streamline the interface.
  • ImGui: Used to create an user interface for real-time control over raytracing parameters like light intensity and reflection settings.

⚙️ Key Highlights


Voxel-Based Raytracing

Built a raytracer that renders voxel structures, allowing for dynamic scenes constructed from 3D grids.
Voxel Volume Transform

Beer’s Law for Light Absorption

Implemented Beer’s Law to simulate light absorption in semi-transparent objects like smoke or glass.
Smoke cloud

Area Lighting for Soft Shadows

Created area lights that cast realistic shadows based on the light source’s size and distance.
Soft Shadows

  • Optimization Techniques: Optimized the raytracing algorithm with:
    • Multithreading: Using multithreading to distribute ray calculations across multiple CPU cores.
    • SIMD (Single Instruction, Multiple Data): Applied SIMD instructions to process multiple rays simultaneously, increasing speed.

📚 Project Articles

Throughout the project, I documented my learning and development process in a series of articles. These posts dive deeper into the various aspects of building a CPU-based raytracer and cover aspects of this project in detail:

  1. Learning-Raytracing-in-8-weeks | Area Lights | Part 1 -n introduction to the project, focusing on area lights and realistic shadow casting.
  2. Learning-Raytracing-in-8-weeks | Glass made out of voxels | Part 2 Techniques for simulating glass effects in a voxel-based raytracer.
  3. Learning-Raytracing-in-8-weeks | Transforming voxel volumes | Part 3 A discussion on implementing transformations within voxel volumes.
  4. Learning-Raytracing-in-8-weeks | Simple Smoke with Beer’s Law | Part 4 An exploration of Beer’s Law to simulate light absorption for semi-transparent objects like smoke.

🎮 Play on itch.io