Skip to content

guillemsrr/raytracing-audio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raytracing Audio 🔊🌟

C++ CMake SDL3 OpenGL

The idea was to create a custom-built C++ core framework designed to unify optical and acoustic phenomena through real-time raytracing. By leveraging a single mathematical foundation, it simulates both the behavior of light (Whitted/Path Tracing) and the propagation of sound through virtual environments. But it is still WIP, just created the raytracing part, no audio yet :)

You can see the devlog on my portfolio website.

Raytraced two-sphere render

🛠️ Technology Stack

  • Language: C++20
  • Framework: SerraEngine (Custom core engine)
  • Windowing & Input: SDL3
  • Graphics API: OpenGL (via GLAD)
  • Math: GLM
  • Build System: CMake (3.20+)

🏗️ Architectural Boundaries

The engine is engineered with strict adherence to SOLID principles and modular design:

  • Core Orchestration: High-level minimal loop, decoupled from the underlying renderer.
  • Agnostic Renderer: The pixel/sample buffer is oblivious to whether it's rendering optical photons or acoustic phonons.
  • Material System: Unified Material structures that contain both optical parameters (Reflectance, Refraction) and acoustic coefficients (Absorption, Scattering).
  • Modern Audio Pipeline: Utilizes the new SDL3 audio stream API (SDL_GetAudioStreamData) instead of legacy audio callbacks for seamless, low-latency playback.

🚀 Building from Source

Prerequisites

  • CMake 3.20 or higher
  • A C++20 compatible compiler (MSVC, GCC, or Clang)
  • SDL3
  • OpenGL development libraries

Build Instructions

# Clone the repository and the SerraEngine dependency
git clone https://github.com/yourusername/raytracing-audio.git
cd raytracing-audio

# Create a build directory
mkdir build && cd build

# Configure with CMake
cmake ..

# Build the project
cmake --build . --config Release

📜 Development Guidelines & Coding Standards

  • Memory Management: Strictly modern C++ idioms (std::unique_ptr, std::shared_ptr). Zero raw new/delete allocations in the high-level logic.
  • Composition over Inheritance: The Entity and Scene structures are built to remain lightweight and extensible.
  • Performance: Hot paths are profiled and optimized for cache coherency. Interface segregation guarantees the Raytracer logic never depends on external APIs like SDL_Window.

📚 Acknowledgements & References

The project has been inspired by various learning resources:

📄 License

This project is open-source and available under the terms of the MIT License.

About

Raytracing in CPU, SDL3

Resources

License

Stars

Watchers

Forks

Contributors