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

607 views

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

In: 24

24 Answers

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.

You are viewing 1 out of 24 answers, click here to view all answers.