Hacker News new | ask | show | jobs
by throway453sde 1622 days ago
Does the 3d games today still use ray tracing or some other algorithm?
2 comments

3D games have basically never used ray tracing. They're starting to, a little bit. Some old 3D games (think Doom-era) used an algorithm called "ray casting", which is similar to ray tracing but much more primitive and much faster - among other simplifications, instead of one ray per pixel, you only have one ray per column.
I might be mistaken but I don't think Doom uses ray casting.
Doom’s predecessor Wolfenstein 3D was famous for using ray casting, and the Doom engine inherited ray casting and extended it to handle different floor heights. https://lodev.org/cgtutor/raycasting.html
That's Wolfenstein 3d though. It's been a few years since I last checked Doom's source code but I don't remember seeing anything about raycasting in it. And a quick search leads me to things like [1] which seem to confirm it. But then all the replies to my comment seem sure that it used raycasting, so maybe I'm missing something.

1. https://www.doomworld.com/forum/topic/71128-so-is-doom-a-ray...

Maybe you’re right! I could be wrong, I was only repeating what I’ve heard second hand and read in blog posts. Looking at the code right now, there is a ray casting function called P_CheckSight() that is used for collision and enemy tests, but isn’t part of the core rendering algorithm. Carmack did say “I used the BSP tree for rendering things” but also that the basic rendering concept is “horizontal and vertical lines of constant Z”. It seems entirely possible that this engine is a sort of hybrid of the category we think of “ray casting”, that it’s not exactly what someone assumes when hearing that phrase, but also not entirely different either.
I think it did but only in one dimension to determine wall distance and then faked everything else.
The early Doom 1 and 2 being software renderers, used ray casting (386 protected mode FTW to boot!) The later versions though, were part of the first wave of games to leverage GPU cards. I don't know if those newer releases still kept any ability to render purely in software though.
Ray tracing is extremely costly for real time rendering and is almost never used unless there is some trickery. We have some limited amount of it now, especially since the Nvidia RTX series of GPUs, but rasterization is still king.

Among the trickery being used is raycasting, used in early 3D games like Doom, which is a kind of 2D ray tracing that works by column instead of by pixel. Real time ray tracing techniques, in particular signed distance field raymarching is a staple of the demoscene, this is made possible by using mathematically defined objects.

For prerendered graphics (ex: Pixar movies), the dominant technique is path tracing, it is a randomized variant of ray tracing that produces a noisy image that is progressively refined. It is even more costly than raytracing, but is much better at global illumination.

An interesting caveat is that ray tracing has a high up-front cost, but rendering time is less sensitive to scene complexity than traditional polygon rasterization. Beyond a certain level of scene complexity, ray tracing can be faster, it's just that games are generally limited by what can fit in memory of a modern graphics card.

Regarding Pixar, they actually avoided ray tracing until they decided they really did need accurate reflections for the movie Cars. The reason is that traditional rendering is memory parallel: you can render a scene that won't fit in memory on a single computer by spreading the scene across a cluster. With ray tracing, the memory access patterns aren't predictable, so you have to have the whole scene fit in memory on every compute node. This doesn't matter for games because games don't divide the graphics computation across multiple machines.