What is Ray tracing?

465 views

I hear about it in video games a lot, but I don’t understand it.

In: Technology

3 Answers

Anonymous 0 Comments

Ray tracing is a way of projecting a model of a 3d world (inside your computer) onto the screen. It creates imaginary rays (lines) from the camera location (your viewpoint) out into the 3d world. The rays measure which object in the world is closest, how close it is, what angle it’s at from your viewpoint, what colour it is, etc, and uses that data to decide where, what colour, and how big it should be displayed on your screen. You could think of it as similar to how bats use echolocation to “see” the room.

On a related note, this is a great book: https://www.goodreads.com/en/book/show/36165638-game-engine-black-book-wolfenstein-3d

Anonymous 0 Comments

Former game developer here,

The traditional means of drawing frames for your display is by projecting the world onto a 2D grid of pixels. It’s quite analogous to the idea of light coming into a camera onto a flat piece of film. Indeed, we often talk about the “camera” as your point of view in the game.

With ray tracing, instead of light coming into the camera and landing on a pixel, it’s light coming out of the pixel, out of the camera, and shining and reflecting all the way back onto the light source. That’s quite literally the computational algorithm – cast a ray, which is just a line through 3D space, until it hits an object in that 3D space, then split and bounce rays from that point of contact outward, again, and again, and again, until all the rays intersect a light source inevitably. Once you do that, you can then sum the light from the source to the effect of every surface it’s touched, all the way back to that one pixel. Each surface is going to change the light, make it a little more of one color or another, include light from another source that’s also shining on that surface and contributing to that pixel…

Now do that for every pixel on your screen. And do that 60-120x per second. If ray tracing sounds computationally expensive, that’s because it is. We try to fake it as much as possible to save our performance budget for other things, but for some effects, there is no substitute.

Anonymous 0 Comments

Ray tracing is a complex subject but to put it simply… It replicates light rays bouncing off of objects in a scene which gives the scene a more realistic feeling.