Note
This repository is still a WIP. Missing features are to be expected.
An open-source raytracing engine built with SDL_GPU.
I really enjoy graphics programming, and I wanted to finally create my own raytracer and create cool renders with it.
In today's wold, there are many great, feature-rich graphics APIs (OpenGL, DirectX, Vulkan, Metal, etc). However, writing cross-platform graphics code is still a bit of a challenge:
- OpenGL is too old;
- Vulkan is too verbose;
- DirectX and Metal are stuck in the Microsoft and Apple mines, respectively;
- I could keep going...
I think that, in situations where Vulkan's lower-level features aren't required, SDL3 is probably the best option for cross-platform graphics applications:
- The new SDL_GPU API provides a nice abstraction layer for apps to talk to modern graphics hardware;
- It's supported on all major operating systems and consoles;
- It's easy to learn and set up.
- Sphere intersection
- 3 physically based materials (lambert, metal and dieletric)
- Defocus blur
- An ImGui window to control camera position, bounces/samples per ray, min/max ray distance, etc.
I tried to keep dependencies on this project to a minimum. Here's what you need to have on your machine in other to compile simple-raytracer:
- a C++ compiler
- CMake
- slangc (for compiling shaders)
- SDL3 (optional)
Note 1: If SDL3 is not installed in your machine, CMake will fetch it from github. ImGui and GML are always fetched from github.
Note 2: If you don't have slangc installed on your machine, I would recommend installing the .
Once all dependencies are installed, run these commands on your terminal:
git clone https://github.com/Rowobin/simple-raytracer.git
cd simple-raytracer
mkdir build
cd build
cmake -B build-native -S ..
cmake --build build-native
./build-native/simple_raytracer.exeThis program uses Slang for its shaders. In addition to that, there are pre-compiled SPIRV and MSL shaders. To compile the shaders yourself, you will need to download the slangc compiler.
slangc shaders.slang -entry computeMain -stage compute -target spirv -o spirv/compute.spv
slangc shaders.slang -entry computeMain -stage vertex -target metal -o metal/compute.metalIf you find any mistakes or think of any improvements to this repository, feel free to send a PR!
This project is licensed using The Unlicense.