Every few years, an amazing new technology appears that promises to make games even more realistic. For decades we’ve had shaders, tessellation, shadow mapping, ray tracing – and now there’s a new kid on the block: path tracing.

- Advertisement -

So if you’re looking for narrow information about this latest development in graphics technology, you’ve come to the right place. Let’s dive into the world of rendering and follow the path of light and learning.

What is path tracing?

- Advertisement -

A short and sweet answer to this question…path tracing is just ray tracingThe equations for modeling the behavior of light are the same, the use of data structures to speed up the search for ray and triangle interactions is the same, and modern GPUs use the same units to speed up the process. intensive.

But wait. If they are really the same thing, then why does path tracing have a different name, and what benefit does it give game programmers? Path tracing differs from ray tracing in that instead of tracking multiple rays throughout the scene, the algorithm only traces the most likely path for the light.

- Advertisement -

Path tracing differs from ray tracing in that instead of tracking multiple rays throughout the scene, the algorithm only traces the most likely path for the light.

We learned how beams work (see: Deeper Dive: Rasterization and Ray Tracing), but a brief overview of the process is required here. The frame starts as usual: the video card renders all the geometry – all the triangles that make up the scene – and stores them in memory.

After a little extra processing, to organize the information so that the geometry can be searched faster, ray tracing comes into play. For each pixel that makes up the frame, one scene ray is emitted from the camera.

Well, not literally – it generates a vector equation with parameters set based on where the camera and pixel are. Then each ray is checked against the geometry of the scene, and this is the first part of the complexity of ray tracing. Luckily, the latest AMD and Nvidia GPUs come with dedicated hardware blocks to speed up this process.

If the ray and the object interact, another calculation is performed to determine exactly which triangle is involved in the model, and the color of the triangle will effectively change the color of the pixel.

But light rarely hits the object, and this light is completely absorbed. There are actually a lot of reflections and refractions going on, so if you want the most realistic rendering possible, new vector equations are generated, one each for reflected and refracted rays.

In turn, these rays are tracked until they also hit the object, and the sequence continues until the chain of rays is finally reflected all the way back to the light in the scene. From the original primary ray, the total number of rays traced through the scene grows exponentially with each reflection.

Rinse and repeat with all the other pixels in the frame and the end result is a realistically lit scene…although it still requires a lot of extra processing to clean up the final image.

But even with the most powerful GPUs and CPUs, it takes a huge amount of time to create a frame with full ray tracing – much, much more than traditional rendering using compute and pixel shaders.

This is where path tracing fits into the picture, if anyone will forgive the pun.

When more work means less work

The original concept of path tracing was presented by James Kajiya back in 1986 when he was a researcher at Caltech. He showed that the problem of stopping a processor working with an ever-increasing number of rays can be solved using statistical scene sampling (in particular, Monte Carlo algorithms).

Traditional ray tracing involves calculating the exact reflection or refraction path of each ray and tracing them to one or more light sources. Path tracing generates multiple rays for each pixel, but they are reflected in a random direction. This repeats when the beam hits the object and continues until either the light source is reached or the specified reflection limit is reached.

On its own, this probably doesn’t seem like a huge change in the amount of computation required, so where’s the magic part?

Not all rays will be used to create the final color of a pixel in a frame. Only a certain number of them will be sampled, and the algorithm uses the results for a nearly perfect light reflection path from the camera to the light source. You can then scale the number of samples for each pixel to adjust the accuracy of the final image.

Despite the extra heap of math and coding, the end result is that far fewer rays are required for processing, even though path tracing typically emits dozens of rays per pixel. Ray tracing and ray interaction calculations cause a performance hit compared to regular rendering, so using fewer rays to color a pixel is definitely a good thing.

But here’s the really smart part: usually fewer rays result in less realistic lighting, but since most of the frame’s pixel color only depends on the primary rays, resetting most or all of the secondary rays doesn’t affect things. as much as you can think.

Now if the scene contains many surfaces that will reflect as well as refract light, such as glass or water, then these secondary rays become important. To work around this issue, either the algorithm is tuned to account for the distribution of ray types to be rendered in the scene, or those particular surfaces are rendered in their own “full ray tracing” render pass.

A good developer will use the full range of rendering tools available: rasterization with shaders, path tracing, and full ray tracing. It takes a lot more work to figure it all out, but ultimately less work is needed for the hardware.

Why is path tracing in the news now?

A few times over the past few years we’ve seen headlines about mods that add ray tracing to the old classics, but most of them actually refer to path tracing. We heard it back in 2019 with an experimental mod. for Crysis as well as Earthquake 2or more recently unofficial Half-Life ray tracing mod and Classic doom mod. Tracking all paths.

There was also a tweet from Dihara Wijetunga, Senior R&D Graphics Engineer at AMD, who announced his project to update the original Return to Castle Wolfenstein game with a path-tracing renderer.

Sample 1

After using path tracing…

Sample 2

Using path tracing…

Sample 3

As noted above, in 2019, Nvidia announced a Quake II remaster with a ray-traced renderer to help advance RTX technology. It was originally the work of one man, Christoph Schiedwho created the remaster (technically known as Q2UCPT) as part of a research project. Thanks to the contributions of other graphics technology experts, Quake 2 RTX was born and became the first known game to use path tracing for all lighting.

The original models and textures are still there, and the only aspect that was changed was how surfaces were lit and shadows were generated. Static images are not the best way to demonstrate how effective a new lighting model is, but you can get a free copy or watch this video…

Banding chills phrases like stochastic sampling of multiple importance as well as variance reduction algorithms, the project emphasized two things: firstly, path tracing looks very cool, and secondly, it is still very difficult for both developers and hardware. If you want to see how difficult math is, read chapter 47 Ray Tracing Gems II.

But if games like Quake II RTX show what can be achieved by tracking all the paths, then games like Control as well as Cyberpunk 2077 demonstrate that incredible graphics can be achieved by mixing all the lighting and shadow techniques – rasterization and shaders still rule the roost, with ray tracing for reflections and shadows.

So we’re still a long way from seeing all games rendered using only path tracing.

On the way to a better future

Despite being relatively new in the world of real-time rendering, path tracing is definitely not going anywhere. We have already seen results in one game and path tracing is already widely used in offline rendering like Blender as well as in the film industry like Autodesk Arnold and Pixar renderman.

So far, there is no sign that GPUs are approaching any limit of their maximum processing power, so while ray tracing, traditional or path tracing, is still very demanding, more powerful hardware will come to the market over the years.

All of this means that developers of future PC games will certainly explore any rendering technique that allows for amazing graphics with achievable performance, and path tracing can do just that.

Current consoles should also be considered. Both the Xbox Series X and PlayStation 5 offer support for “traditional” ray tracing, but given that their GPUs will be relatively obsolete in just a few years, developers will try to use every means possible to squeeze out the last vestiges of shutting down these machines before move on to next generation consoles.

So you have path tracing, a fast relative of ray tracing. Looks almost as good, works a hell of a lot faster. With the constant improvement in graphics technology and performance in home PCs and consoles, we will soon see computer graphics from the latest blockbusters and in our favorite games.

Keep reading. Explainers at tech spot