光线追踪(Ray tracing)是一种先进的计算机图形学形式,可以模拟光在现实生活中的工作方式。它可以创建看起来真正逼真的计算机图形。
过去,光线追踪(ray tracing)仅限于大型计算机图形项目,例如好莱坞 CG(Hollywood CG)电影。现在它出现在PC 游戏(PC gaming)中,很快就会出现在下一代游戏机中。
为了理解为什么这让这么多人兴奋,我们需要将光线追踪图形与迄今为止一直使用的主流图形渲染方法进行比较:光栅化。
光栅化与光线追踪(Rasterization vs Ray Tracing)
现代实时计算机图形看起来很棒!很难想象它与二十或三十年前的基本 3D 图形有什么关系。事实上,像Playstation 1和当前的Playstation 4这样的控制台使用相同的基本方法来渲染 3D 图形,然后将其放到 2D 屏幕上。
这称为光栅化(rasterization)。“光栅”是显示为像素网格的图像,这正是您的屏幕显示的内容。光栅化(Rasterization)是将 3D 场景转换为屏幕上的 2D 图像的过程。
这需要完成,因为 3D 场景是 3D 的。它具有深度,因此虚拟对象可以相互移动并从任何角度观看。在光栅化过程中,如果你的屏幕基本上是进入那个 3D 世界的窗口,计算机必须弄清楚那个场景会是什么样子。
在现实生活中,场景具有纹理和光照(texture and lighting),以及形状、深度和大小(depth and size)。由于模拟光传统上比任何家用计算机都需要更多的(home computer)计算机(computer power)能力,因此程序员已经创造了技巧和捷径来使用这种光栅化过程创建看起来接近真实光、颜色和纹理的东西。(color and texture)
一方面,光线追踪(Ray tracing)要简单得多。它没有尝试使用一长串的技巧来创造真实的光感,而是模拟真实的光线。现在,当计算机必须弄清楚通过屏幕的“窗口”看到的场景会是什么样子时,它只需要运行光线追踪模拟就可以了。
在现实世界中,进入您眼睛的光线在到达您的视网膜之前已经从您正在查看的所有其他物体上反射回来。光线(Ray)追踪以更有效的方式实现了相同的结果。它通过从“相机”拍摄模拟的“光线”并让它在虚拟场景周围反弹,在途中获取颜色和亮度信息来做到这一点。(color and brightness information)您的屏幕代表虚拟眼睛,因此您可以看到一个真正逼真的虚拟世界。
通过使用光线追踪(ray tracing),单一技术可以创建看起来真实的场景中的对象、反射、阴影和其他元素。这种真实感是模拟的自然结果,不需要任何技巧或捷径!
在哪里体验光线追踪(Where To Experience Ray Tracing)
如果您想看到光线追踪的实际效果,您所要做的就是观看任何使用计算机生成图形的现代电影。如果你看一部CG 电影(CG film),比如《玩具总动员 4》(Toy Story 4),你所看到的一切都是光线追踪(ray tracing)的产物。
如果您想探索交互式光线追踪世界,目前城里只有一款游戏。RTX 系列 Nvidia GPU(RTX series of Nvidia GPUs)以及支持该技术的视频游戏和应用程序。您可以使用非RTX 硬件(RTX hardware)运行一些光线追踪应用程序,但不会获得良好的性能。请务必查看我们关于展示RTX 硬件(RTX hardware)的最佳游戏的文章。
问题是RTX 硬件(RTX hardware)仍然相当昂贵。然而,下一代视频游戏机支持光线追踪。这意味着主流游戏世界可能有助于将光线追踪转变为下一个主要的游戏技术。尽管如此,如果实时进行光线追踪如此困难,那么这些新的GPU 是如何管理(GPUs manage)它的呢?
实时光线追踪是如何实现的?(How Is Real Time Ray Tracing Achieved?)
任何计算机都可以使用光线追踪渲染 3D 场景。使用 3D 渲染包的人已经做了很多年了。任何现代CPU都可以执行追踪场景周围光线路径所需的实际计算。
然而,现代CPU 和 GPU(CPUs and GPUs)无法快速处理这些数字以实时生成图像。例如,用于制作《怪物(Monsters) 公司》或《玩具总动员》(Inc or Toy Story)等电影的大型计算机农场需要数小时才能渲染最终产品的单帧。
相比之下,现代视频游戏需要每秒至少生成 30 帧图像才能被认为是可玩的,目前黄金标准设定在每秒 60 帧左右。
那么像Nvidia RTX 系列(Nvidia RTX series)这样的 GPU 如何能够以可播放的帧速率使用光线追踪方法呢?答案是他们不会对所有事情都使用光线(t use ray)追踪。至少在现代标题中没有。
诀窍是将传统图形与选择性光线追踪相结合。RTX卡具有专用的光线追踪硬件,位于更传统的GPU上。这样,光线追踪可以用来弥补传统图形硬件的一些不足。
您(are) 可以使用完全光线追踪的RTX 卡(RTX card)玩一些视频游戏。(video game)最好的例子是Quake II RTX。这是一款已有数十年历史的视频游戏(video game),它非常简单,可以实现完整的实时光线追踪。然而,当谈到将纯光线追踪应用到当前的视频游戏(video game)时,这种硬件成为主流还需要几年的时间。
光线追踪是未来吗?(Is Ray Tracing the Future?)
简短的回答是肯定的,光线追踪(ray tracing)是未来。更长的答案是,随着使实时光线追踪(ray tracing)成为可能的硬件变得更便宜,我们可能会看到它逐渐取代传统的渲染。如果光线追踪图形成为新一代控制台的正常组成部分,那么就没有回头路了。
开发人员可以安全地在其作品中包含光线追踪功能,因为所有流行的平台都会支持它。由于光线追踪图形非常出色,因此明星们确实在为光线追踪在经济实惠的硬件上的到来而努力。这意味着真正的写实主义可能终于出现了。
光线追踪将成为主流渲染方法(rendering method)的另一个主要迹象是它现在如何被包含在开发人员用于制作视频游戏和其他 3D 应用程序的常用工具中。换句话说,开发人员不再需要发明自己的光线追踪解决方案。
Unreal Engine 4或Frostbite等流行的图形引擎现在包括对RTX硬件加速光线追踪的支持。使开发人员更有可能将其作为其标题的选项。
您现在应该购买光线追踪吗?(Should You Buy Into Ray Tracing Now?)
在撰写本文时,我们仍处于第一代光线追踪硬件的阶段。虽然价格有所下降,但性能仍然相当平庸。如果您是铁杆的早期采用者,那么 PC 上的光线追踪有很多值得您喜欢的地方。
如果您不愿意花费数百或数千美元作为早期采用者,最好投资于承诺采用该技术的下一代主流游戏机,或者等待RTX 20 系列显卡的继任者。
OTT Explains: What Is Ray Tracing?
Ray tracing is an advanced form of computer graphics that ѕimulates the way light works in real life. It can create computer graphics that look truly photorealistic.
In the past, ray tracing was limited to massive computer graphics projects, such as Hollywood CG films. Now it’s found in PC gaming and soon, next generation gaming consoles.
To understand why this has so many people excited, we need to compare ray-traced graphics to the mainstream graphics rendering method that’s been used until now: rasterization.
Rasterization vs Ray Tracing
Modern real-time computer graphics look amazing! It’s hard to imagine that it has anything to do with the basic 3D graphics from twenty or thirty years ago. The truth is that a console like the Playstation 1 and the current Playstation 4 use the same basic method of rendering 3D graphics and then putting it on your 2D screen.
This is known as rasterization. A “raster” is an image shown as a grid of pixels, which is exactly what your screen displays. Rasterization is the process of converting a 3D scene into a 2D image on a screen.
This needs to be done, because the 3D scene is, well, 3D. It has depth, so the virtual objects can move past each other and be looked at from any point of view. In the process of rasterization, the computer has to figure out what that scene would look like if your screen was basically a window into that 3D world.
In real life, a scene has texture and lighting, as well as shape, depth and size. Since simulating light has traditionally taken more computer power than any home computer is capable of, programmers have created tricks and shortcuts to create something that looks close to real light, color and texture using this process of rasterization.
Ray tracing is, in one way, much simpler. Instead of trying to use a long list of tricks to create the illusion of real ight, it simulates real light instead. Now when the computer has to figure out what the scene would look like seen through the “window” of your screen, it just runs the ray tracing simulation and it all works out.
In the real world, the rays of light entering your eye have bounced off everything else you are looking at before reaching your retinas. Ray tracing achieves the same result in a more efficient way. It does this by shooting simulated “rays” of light from the “camera” and letting it bounce around the virtual scene, picking up color and brightness information on the way. Your screen represents the virtual eye, so you see a truly realistic virtual world.
By using ray tracing, a single technique creates objects, reflections, shadows and other elements of a scene that look real. That realism happens naturally as a result of the simulation, no tricks or shortcuts needed!
Where To Experience Ray Tracing
If you want to see ray tracing in action, all you have to do is watch any modern movie that uses computer-generated graphics. If you watch a CG film such as Toy Story 4, everything you’re seeing is a product of ray tracing.
If you want to explore an interactive ray-traced world, there’s currently only one game in town. The RTX series of Nvidia GPUs, along with video games and apps that support this technology. You can run some ray-tracing applications with non-RTX hardware, but you won’t get good performance. Be sure to check out our article on the best games that show off RTX hardware.
The problem is that RTX hardware is still quite expensive. However, the upcoming generation of video game consoles have a form of ray-tracing support. Which means that the mainstream gaming world may help turn ray-tracing into the next major gaming technology. Still, if ray-tracing is so difficult to do in real time, how do these new GPUs manage it?
How Is Real Time Ray Tracing Achieved?
Any computer can render a 3D scene using ray tracing. People who work with 3D rendering packages have been doing it for years. Any modern CPU can perform the actual calculations needed to trace the path of light around the scene.
However, modern CPUs and GPUs can’t crunch those numbers quickly enough to generate an image in real time. For example, the massive computer farms used to make films such as Monsters Inc or Toy Story take hours to render a single frame of the final product.
Modern video games, by contrast, need to generate at least thirty frames of images every second to be considered playable, with the gold standard currently set around the 60 frames per second mark.
So how can GPUs such as the Nvidia RTX series manage to use the ray-tracing method at playable frame rates? The answer is that they don’t use ray tracing for everything. At least not in modern titles.
The trick is to combine traditional graphics with selective ray-tracing. The RTX cards have dedicated ray-tracing hardware that sits along a more traditional GPU. In this way, ray-tracing can be used to compensate for some of the shortcomings of traditional graphics hardware.
There are video games you can play with an RTX card that are fully ray-traced. The best example is Quake II RTX. This is a decades-old video game that is simple enough that full real-time ray-tracing is possible. When it comes to applying pure ray-tracing to current video games however, it will still be years before such hardware becomes mainstream.
Is Ray Tracing the Future?
The short answer is yes, ray tracing is the future. The longer answer is that as hardware that makes real-time ray tracing possible becomes cheaper, we’ll probably see it replace traditional rendering bit by bit. If ray-traced graphics become a normal part of the new console generation, there will be no going back.
Developers can safely include ray-tracing features in their titles, because all popular platforms will support it. Since ray-traced graphics are superior, the stars really are aligning for the arrival of ray-tracing on affordable hardware. Which means that true photorealism may finally be here.
The other major sign that ray-tracing will become a mainstream rendering method is how it’s now being included in the common tools that developers use to make video games and other 3D applications. In other words, it’s no longer necessary for developers to invent their own ray-tracing solutions.
Popular graphics engines such as Unreal Engine 4 or Frostbite now include support for RTX hardware-accelerated ray-tracing. Making it much more likely that developers will include it as an option for their titles.
Should You Buy Into Ray Tracing Now?
At the time of writing, we are still at the first-generation of ray-tracing hardware. While prices have come down, performance is still pretty mediocre. If you’re a hardcore, early adopter then there’s plenty to like about ray-tracing on PC.
If you aren’t willing to spend hundreds or thousands of dollars as an early adopter, it’s better to invest in the next generation of mainstream consoles which promise to feature the technology, or wait for the successor to the RTX 20-series cards.