Engineering Explained: Ray Tracing

October 25, 2020

There is a new hot topic on the tech scene right now called Ray Tracing. I assume some Engineers have heard it thrown around in conversation, but still might not know exactly what it is. Well, today we plan on clarifying that understanding in this segment of Engineering Explained. 

Ray Tracing is used in computer generated movies, video games, and special effects in live action movies. By this point, you have seen it whether you realize it or not. The problem is, it has always been thought of as “computationally expensive,” but that has changed within the last few years. 

The formal definition of Ray Tracing according to Wikipedia is, “a rendering technique for generating an image by tracing the path of light as pixels in an image plane and simulating the effects of its encounters with virtual objects.” I think of Ray Tracing in this manner: Imagine you’re playing pool with some of your friends. Your friend just scratched her last shot, so you’re up next. You walk up to the pool table and line up your shot. Your intention is to sink the 3 ball into the corner pocket at the other end of the table. You pull your stick back and strike the cue ball dead center and send it racing down the table in a straight line. It strikes the intended ball but immediately begins following a new path along the angle of reflection. It coasts along that new path, slowing losing momentum, until it comes to a stop in front of your friend standing on the side of the table. 

Now, to put this example in terms of Ray Tracing, all we have to do is follow it in reverse. Imagine your friend is a light source emitting photons of lights. One of those photons is the cue ball. It travels along in a straight line until it hits another object, in this case a ball, and reflects off of it at an angle, which happens to be in your direction. It travels in that second straight line until it hits you. The cue ball is a photon of light striking your point of view. Put simple, Ray Tracing is merely “tracing” the path of light emitted from a light source, calculating if it will intercept with your view angle, and then rendering out any intercepted Rays as a frame. (Note from Eric: Except, it’s all done in reverse: traced from the point of view outwards, which is more efficient.) Now, this is a simple example with only one Ray. Computers use hundreds of thousands of Rays for each light source and sometimes even use billions of Rays (Thank you, Eric!) for a complex scene containing multiple light sources. The more “Rays” you trace, the more convincing the lighting effect.

As you can imagine, this is all computationally taxing. It takes a lot of power to produce even one frame of a scene like this. CPUs can’t keep up with this sort of demand. That’s why this is primarily the domain of graphics processing units, or graphics cards. Graphics cards, without going into too much detail, contain several orders of parallel processing units that can work on the same workload at the same time. That means that processing 10s of billions of Rays at the same time for one frame of a game takes fractions of a second. If a game is running at 60 frames per second, that allows for roughly 16 milliseconds per frame. That is a tiny fraction. You’ve got 16 ms to render everything.

There are a lot of benefits to this type of render method. Fist off, lighting looks more realistic. Light is rendered just as we see light in real life. Scenes looks more natural to us. Plus, lighting is far more dynamic, because light is generated by objects in a scene. If an object is removed from a scene, it no longer casts Rays and the scene becomes a little bit darker. An added benefit is that shadows are rendered at no cost to the graphics card. They just come along for free. Shadows are also more accurately rendered, because they are a function of the light sources included in a scene. In the same way multiple light sources are traced at different angles, so are shadows. A shadow is just the absence of light with this rendering method.

So, get ready for the holidays when you will be able to experience this light rendering method on your XBOX Series X, PlayStation 5, and AMD and nVidia GPUs. 

Ian’s Take

I’ve seen the light of Ray Tracing and I am excited to see it gain more traction in the gaming space. Even Quake got a new version with Ray Tracing.  

Comments are closed.