what is raytracing? I see this term a lot relating to video games and 3D animations

585 views

Thanks for the replies everyone, I think I get it now

In: 24

24 Answers

Anonymous 0 Comments

When you sit in a dark room and light a match photons immediately fill the room bouncing of objects in that room in ways that allow your brain to make excellent guesses about their size shape and position. Your brain is really really good at this which is why [this illusion](https://upload.wikimedia.org/wikipedia/commons/thumb/b/be/Checker_shadow_illusion.svg/1920px-Checker_shadow_illusion.svg.png) works so well (the two squares A and B are the same color).

A computer needs to do something similar if your video game avatar lights a match in a dark room so I can put shadows and illuminate different parts of the room in ways your eyes will consider normal.

A distant wall should be dimmer than a close wall, shadows should be on the opposite side of the light source. And things like that.

To do this a computer needs to know how the position and shapes of the objects in the room interact. One way to do that is to draw many straight lines from a light source around the room. That’s called ray (straight line) tracing.

Anonymous 0 Comments

Say you want to paint a 3D scene on a 2D canvas. The 3D scene is given to you as a giant spreadsheet of the 3D coordinates of the corners of say 1,000 triangles.

The “traditional” way to draw the 3D scene is to calculate where the corners of the triangles will be in 2D, assuming a specific position and direction of the “camera” (you can just put some new columns in the spreadsheet). Then you just have to go through the spreadsheet and paint the calculated 2D triangles. (There’s a bit of trickery involved in deciding when you need to paint over a triangle you’ve already painted.) You can handle lighting by another calculation involving the light source.

Ray tracing is different from the “traditional” way. For ray tracing, you instead do it in reverse, you divide your canvas into a grid, then calculate the angle of a beam of light entering the “camera” through that part of the canvas, then trace the beam backwards to see which triangle it hits, then continue to trace it backwards from that hit to the light source.

Ray tracing generally produces better looking, more realistic scenes. It handles shadows and reflections very well. It’s good at dealing with curved shapes that aren’t made up of triangles.

The main problem with raytracing is that it takes a lot more calculations.

For a movie it doesn’t matter if it takes 5 minutes to calculate a frame, the movie studio can take weeks and spend $100,000’s or more on as many computers as it needs to calculate all the frames of the movie. Ray tracing has been used for movies for a long time (think Toy Story and Shrek in the 1990’s).

For a video game, you need to get 60 frames per second on a computer that’s affordable to the average person. So ray tracing can’t be used in video games, it’s just too slow. (Except of course for stuff pre-created by the development studio, like in-game movies (cutscenes)). Except in the last couple years, GPU’s have gotten so ridiculously powerful that it may be possible to do ray tracing fast enough to use for video games. Which would be a big change.

[This video](https://www.youtube.com/watch?v=Qz0KTGYJtUk) has some pretty good explanations of ray tracing.

Anonymous 0 Comments

Say you want to paint a 3D scene on a 2D canvas. The 3D scene is given to you as a giant spreadsheet of the 3D coordinates of the corners of say 1,000 triangles.

The “traditional” way to draw the 3D scene is to calculate where the corners of the triangles will be in 2D, assuming a specific position and direction of the “camera” (you can just put some new columns in the spreadsheet). Then you just have to go through the spreadsheet and paint the calculated 2D triangles. (There’s a bit of trickery involved in deciding when you need to paint over a triangle you’ve already painted.) You can handle lighting by another calculation involving the light source.

Ray tracing is different from the “traditional” way. For ray tracing, you instead do it in reverse, you divide your canvas into a grid, then calculate the angle of a beam of light entering the “camera” through that part of the canvas, then trace the beam backwards to see which triangle it hits, then continue to trace it backwards from that hit to the light source.

Ray tracing generally produces better looking, more realistic scenes. It handles shadows and reflections very well. It’s good at dealing with curved shapes that aren’t made up of triangles.

The main problem with raytracing is that it takes a lot more calculations.

For a movie it doesn’t matter if it takes 5 minutes to calculate a frame, the movie studio can take weeks and spend $100,000’s or more on as many computers as it needs to calculate all the frames of the movie. Ray tracing has been used for movies for a long time (think Toy Story and Shrek in the 1990’s).

For a video game, you need to get 60 frames per second on a computer that’s affordable to the average person. So ray tracing can’t be used in video games, it’s just too slow. (Except of course for stuff pre-created by the development studio, like in-game movies (cutscenes)). Except in the last couple years, GPU’s have gotten so ridiculously powerful that it may be possible to do ray tracing fast enough to use for video games. Which would be a big change.

[This video](https://www.youtube.com/watch?v=Qz0KTGYJtUk) has some pretty good explanations of ray tracing.

Anonymous 0 Comments

Say you want to paint a 3D scene on a 2D canvas. The 3D scene is given to you as a giant spreadsheet of the 3D coordinates of the corners of say 1,000 triangles.

The “traditional” way to draw the 3D scene is to calculate where the corners of the triangles will be in 2D, assuming a specific position and direction of the “camera” (you can just put some new columns in the spreadsheet). Then you just have to go through the spreadsheet and paint the calculated 2D triangles. (There’s a bit of trickery involved in deciding when you need to paint over a triangle you’ve already painted.) You can handle lighting by another calculation involving the light source.

Ray tracing is different from the “traditional” way. For ray tracing, you instead do it in reverse, you divide your canvas into a grid, then calculate the angle of a beam of light entering the “camera” through that part of the canvas, then trace the beam backwards to see which triangle it hits, then continue to trace it backwards from that hit to the light source.

Ray tracing generally produces better looking, more realistic scenes. It handles shadows and reflections very well. It’s good at dealing with curved shapes that aren’t made up of triangles.

The main problem with raytracing is that it takes a lot more calculations.

For a movie it doesn’t matter if it takes 5 minutes to calculate a frame, the movie studio can take weeks and spend $100,000’s or more on as many computers as it needs to calculate all the frames of the movie. Ray tracing has been used for movies for a long time (think Toy Story and Shrek in the 1990’s).

For a video game, you need to get 60 frames per second on a computer that’s affordable to the average person. So ray tracing can’t be used in video games, it’s just too slow. (Except of course for stuff pre-created by the development studio, like in-game movies (cutscenes)). Except in the last couple years, GPU’s have gotten so ridiculously powerful that it may be possible to do ray tracing fast enough to use for video games. Which would be a big change.

[This video](https://www.youtube.com/watch?v=Qz0KTGYJtUk) has some pretty good explanations of ray tracing.