This repo contains my implementation of the first book of Ray-Tracing in One Weekend using the DirectX 12 RayTracing(DXR) API.
Ray-tracing is a rendering technique that brings an extra level of realism to computer graphics. It emulates the way light reflects and refracts in the real world, providing a more believable environment than what’s typically seen using other rendering techniques.
The technique sends a ray from a virtual "eye" (or camera) through each pixel in the screen, let it hit the scene's objects and bounce from them. The ray might hit other objects and might hit a light source, collecting their illuminance and color. In practicality to avoid noise, many rays(samples) need to be sent for each pixel.
While the technique has been around for many decades, it was unusable for the gaming industry due to its very intensive processing demands. It was used mainly in the movie industry in which every frame can be rendered in advance.
Nowadays, thanks to advances in GPU hardware such as NVIDIA's RTX series and smart APIs such as Microsoft's DXR, real time ray-tracing becomes possible. This project will demonstrate it.
At the 2018 Game Developer's Conference, Microsoft introduced an addition to DirectX 12 called DirectX Raytracing (DXR), an API allowing easy use of GPU-accelerated ray tracing in DirectX and allowing simple interoperability with traditional DirectX rasterization.
Ray-Tracing in One Weekend is an excellent online tutorial for implementing a ray-tracer(technically a path-tracer) with C++. The tutorial walks the user through:
- writing a basic camera.
- sending rays fron the camera and letting them bounce in the scene
- constructing a scene containing matte, metal, and glass (dielectric) materials.
The output result is a single image which can take even an hour to render. My project, depending on the GPU that runs it and the parameter number of samples per pixel, can render at 30 frames per second
Build the D3D12Raytracing.sln solution and run the executable.
The only dependency is assimp, an asset loading library. The project currently build with version 5.2.5. You can build it from source and update the project's include directories and input libraries location.