How does the real-time ray tracing work in the computer 3D graphics?


I have been hearing about the new types RTX graphics cards that can do ray tracing real time. I know how the light radiation works in real life and previously -unless you wanted a still ray traced image that took long time to calculate- you had to use computer trickery to render effects that simulate in moving 3D. Now with the new RTX-type graphics cards how close are we to how the real light works in real-time computer 3D space? Just how does it work?

In: Technology

I’ve written a longer answer to this before, but here’s a summary: traditional ray (and/or path) tracing is slow, because there are so many rays to simulate and the simulation of an individual ray is slow if the scene has a lot of complexity. RTX-style ray tracing improves these in 3 ways.

– The GPU is used for ray tracing instead of the CPU, which works because GPUs are designed to do thousands of computations at the same time.
– Individual ray simulation is made faster by dedicated hardware on the GPU that can be used to quickly test which objects and rays can intersect, which usually takes a lot of time.
– The number of required rays can be significantly reduced with the use of state of the art denoising and resolution scaling algorithms. Normally a ray tracer needs to simulate many rays per pixel to get a good result, but with denoising one ray (or less) can be enough.

The technique is very similar to rendered ray tracing. As with many rendering techniques, GPUs get fast enough and specialised enough that they can do the rendering in a 30th of a second or faster.

So how it works, is that an algorithm projects “rays” into a scene from the “camera”, and simulates them bouncing off objects towards the light source. Kind of the reverse of how we see in real life. It then uses this to approximate the colour value of the pixels. The end results is a much higher level of realism than what you could achieve with traditional rendering methods alone. Including accurate lighting, shadows, and realistic reflections off surfaces, without cheating using textures or additional objects.

Ray tracing has been used in professional CGI for a while now, but it’s very computationally expensive due to the complex math involved. So rending ray traced scenes in real time, at playable frame rates, is only a recent innovation. The technology is still very much in its infancy though. Nvidia’s method is to have a separate co-processor of sorts on their RTX cards to handle these calculations. But even then, games still take a huge performance hit with it turned on. It’ll take time for game engines and hardware to really start optimizing code for it. Which will likely happen with the next console generation.