This C++ project, developed for the course on Graphic Processors in Computational Applications at the Faculty of Mathematics and Information Science at WUT, implements a ray tracing simulation using CUDA Toolkit 12.2. The project is compiled in Visual Studio 2022 and optimized for Release mode. Heavily inspired by TheCherno's series on ray tracing in C++.
By default, the simulation runs on GPU, offering an option in the Menu to switch to CPU. The scene includes 1000 spheres and 10 light sources.
For each pixel, a ray is cast from the camera, and each ray corresponds to a separate thread. The simulation checks for sphere intersections, applying the Phong lighting model to calculate pixel colors.
In the shadow-enabled version (selectable in the menu), rays are reflected to all light sources. New rays are created, checking for additional sphere intersections on the path from the light source to the reflection point.
Camera controls are outlined in the Menu under the Camera Controls section. The project incorporates projection and view matrices along with texture resizing for dynamic window size changes and automatic resolution adjustments
- Sky color: Color of a pixel where the ray doesn't hit any sphere.
- Ambient light color: Color of ambient light.
- Sphere material: Parameters for the Phong lighting model (diffuse, specular, shininess, ambient).
- Attenuation: Light strength, determining how light intensity changes with increasing distance from the object.
- Light positions
- Light colors
- Disable lights
- write from CUDA to texture buffer directly
- further optimalization (kd-tree...)
- physically based rendering


