DirectX Ray Tracing: the Quest for the Holy Grail
THE NEXT GENERATION of Microsoft’s DirectX API, DirectX Raytracing (DXR), is intended to bridge the gap between rasterization and ray tracing, allowing for new and increasingly realistic renderings. But what exactly is ray tracing, and why do we need it?
The holy grail of computer graphics has been figuring out how to create a perfect rendition of the world around us. Imagine trying model the way the world appears to your eyes. Photons bounce around, emitted from light sources such as the sun, light bulbs, our monitors, or are reflected off other objects. These photons reach the receptors in our eyes, and our brain interprets all of this as an image.
The problem with modeling this is that it all happens on an analog level. Photons are always being emitted, at different rates and wavelengths. A single light bulb emits around 2 x 1020 photons per second—never mind the sun. Simulating every photon bouncing around the world is impractical, and we need something else: ray tracing.
Ray tracing flips the model around and only simulates the photons that would hit a surface— your eye or, in this case, a flat display. Reverseproject a path from each pixel of your display into an environment model, then calculate the final color of each pixel based on reflection, refraction, texture, and absorption properties of the materials. This gives you a decent approximation of the physically modeled view of the environment. The problem is that doing this requires a lot of calculations. The latest Pixar movies are rendered on hundreds of computers, and it still take hours to generate each frame. Games, meanwhile, try to render in real time, at 60fps or more. That’s just a bit faster than six hours per frame.
Games do this by approximating graphics in a process known as rasterization. It uses 3D models and textures, with various methods of calculating lighting and colors, to create a 2D representation of a 3D environment. It’s generally fast and works well enough, with games becoming increasingly realistic every year. Now rasterization has started using complex techniques such as screen space reflections, global illumination, environment mapping, and more.
If the end goal is to get the best approximation of the way things look in the real world, we circle back to ray tracing. Microsoft’s DXR builds on the compute capabilities of the DX12 API, without requiring new hardware, to create a new model for data and graphics. It’s a computational workload, which is possible now that our GPUs have replaced most fixed function units with general-purpose gear running shader programs.
DXR doesn’t mean we’re going to suddenly start playing fully raytraced games, however. Ray tracing is more computationally intensive than rasterization, but it allows for new rendering techniques that improve image quality. DXR gives developers a way to shift things like screen space reflections and true global illumination to the new API, with better results and less effort.
Ray tracing isn’t a crazy idea that game developers don’t want and will never use. If real-time ray tracing becomes possible without a major performance hit, game developers will investigate its uses. Instead of spending resources generating shadowmaps and calculating hacks to simulate the way things should look, ray tracing does the heavy lifting, allowing the artists to focus their energies on creating a great model of their world, and letting the engine do the rendering.
As proof of the interest in DXR, EA, Epic, Unity, and others are already working with it, and early GDC demos show promise. Nvidia has also created Ray Tracing for Gameworks ( RTX) built on DXR, promising enhanced performance on Volta graphics chips. That suggests new GeForce cards with enhancements for RTX may be near.
We won’t see an immediate transition to ray tracing—GPUs still need to be supported—but we should start seeing forms of it used to improve image fidelity quite soon.