This repo contains the code for a Raytracer written in C# using Windows Forms. Raytracing is highly parallelizable task so allowing the code to run on the GPU, using OpenCL, was a necessity for fast realtime results. The ray tracer supports backgrounds, spheres, disks, reflections, and refractions.
Ray tracing is a 3D rendering technique. Some alrternatives are rasterazation and ray marching. Ray tracing works by simulating individual light rays. Instead of originating the light rays at the light source, where they start their hourney in real world, the light rays start from camera. They then shoot out into the scene until they hit an object. If the object is reflective then that ray is reflected off of the surface and bounces again through the scene. If the object is refractive, think glass, then the ray is refracted through the object. The maximum number of bounces of light allowed is called the max depth.
With a depth of 1 you can see objects
With a depth of 2 you can see reflections of objects
With a depth of 3 you can see reflections of reflections of objects
Feel free to use the code whatever purposes you like.
Please note that the background photo is not mine.
Photo Credit: Sitoo Serra del Cavall Bernat, Pollença, Mallorca via photopin (license)