Unity Global Illumination(Unity 全局光照 ) 官方手册笔记系列之Global Illumination(全局光照)

Global Illumination(全局光照)

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.1版本
参考链接:https://docs.unity3d.com/Manual/GIIntro.html

Global Illumination (GI) is a system that models how light is bounced off of surfaces onto other surfaces (indirect light) rather than being limited to just the light that hits a surface directly from a light source (direct light). Modelling indirect lighting allows for effects that make the virtual world seem more realistic and connected, since objects affect each other’s appearance. One classic example is ‘color bleeding’ where, for example, sunlight hitting a red sofa will cause red light to be bounced onto the wall behind it. Another is when sunlight hits the floor at the opening of a cave and bounces around inside so the inner parts of the cave are illuminated too.
全局光照(GI)是一个模拟光从表面反射到其他表面(间接光),而不是仅仅局限于直接从光源(直接光)照射到表面的光照系统。模拟间接照明可以使虚拟世界看起来更真实、更有联系,因为物体会影响彼此的外观。一个经典的例子是“渗色”,例如,阳光照射在红色的沙发上,会导致红色的光线反射到后面的墙上。另一种是当阳光照射到洞穴的底部,并在洞穴里面反射,这样洞穴的内部也被照亮。
这里写图片描述
Global illumination in the Scene View. Note the subtle effect of indirect lighting.
场景视图中的全局照明。注意间接照明的微妙效果。

GI concepts

Traditionally, video games and other realtime graphics applications have been limited to direct lighting, while the calculations required for indirect lighting were too slow so they could only be used in non-realtime situations such as CG animated films. A way for games to work around this limitation is to calculate indirect light only for objects and surfaces that are known ahead of time to not move around (that are static). That way the slow computation can be done ahead of time, but since the objects don’t move, the indirect light that is pre-calculated this way will still be correct at runtime. Unity supports this technique, called Baked GI (also known as Baked Lightmaps), which is named after “the bake” - the process in which the indirect light is precalculated and stored (baked). In addition to indirect light, Baked GI also takes advantage of the greater computation time available to generate more realistic soft shadows from area lights and indirect light than what can normally be achieved with realtime techniques.
传统上,视频游戏和其他实时图形应用程序仅限于直接照明,而间接照明所需的计算速度太慢,因此只能在非实时情况下使用,比如CG动画电影。游戏在这个限制下工作的一种方法是,只针对那些预先知道的不移动的物体和表面计算间接光(这是静态的)。这样,慢速的计算就可以提前完成,但是由于物体不移动,所以预先计算的间接光在运行时仍然是正确的。Unity支持这种技术,叫做“烘焙GI”(也称为烘焙光照图),它是以“烘烤”的方式命名的——间接光被预先计算和存储(烘焙)的过程。除了间接光外,烘焙GI还利用了更大的计算时间来产生更真实的来自区域光和间接光的软阴影,而不是实时技术所能达到的效果。

Additionally, Unity 5.0 adds support for a new technique called Precomputed Realtime GI. It still requires a precomputation phase similar to the bake mentioned above, and it is still limited to static objects. However it doesn’t just precompute how light bounces in the scene at the time it is built, but rather it precomputes all possible light bounces and encodes this information for use at runtime. So essentially for all static objects it answers the question “if any light hits this surface, where does it bounce to?” Unity then saves this information about which paths light can propagate by for later use. The final lighting is done at runtime by feeding the actual lights present into these previously computed light propagation paths.
此外,Unity 5.0增加了一种名为“预计算实时GI”的新技术的支持。它仍然需要一个类似于上面提到的烘焙的预计算阶段,并且它仍然局限于静态对象。然而,它并不只是预先计算出在构建时光线如何在场景中反射,而是预先计算所有可能的光反射,并对这些信息进行编码,以便在运行时使用。所以对于所有的静态对象来说它回答了一个本质上的问题:”如果有任何光线照射到这个表面,它会反射到哪里?” 然后,Unity保存了关于光可以传播哪些路径的信息,以便以后使用。最后的照明是在运行时通过将实际的光输入到这些先前计算的光传播路径中完成的。

This means that the number and type of lights, their position, direction and other properties can all be changed and the indirect lighting will update accordingly. Similarly it’s also possible to change material properties of objects, such as their color, how much light they absorb or how much light they emit themselves.
这意味着灯的数量和类型、它们的位置、方向和其他属性都可以改变,间接照明也会相应更新。同样,也可以改变物体的材质属性,比如它们的颜色,它们吸收多少光,或者它们发出多少光。

While Precomputed Realtime GI also results in soft shadows, they will typically have to be more coarse-grained than what can be achieved with Baked GI unless the scene is very small. Also note that while Precomputed Realtime GI does the final lighting at runtime, it does so iteratively over several frames, so if a big a change is done in the lighting, it will take more frames for it to fully take effect. And while this is fast enough for realtime applications, if the target platform has very constrained resources it may be better to to use Baked GI for better runtime performance.
虽然预计算的实时GI也会导致软阴影,但它们通常必须比烘焙GI更粗粒度,除非这个场景非常小。还要注意的是,虽然预计算的实时GI在运行时完成了最终的照明,但它需要在几帧上进行迭代,所以如果在照明中做了一个大的改变,那么它将需要更多的帧来完全生效。虽然这对于实时应用来说已经足够快了,但是如果目标平台的资源非常有限,那么最好使用烘焙的GI来获得更好的运行时性能。

Limitations of GI
Both Baked GI and Precomputed Realtime GI have the limitation that only static objects can be included in the bake/precomputation - so moving objects cannot bounce light onto other objects and vice versa. However they can still pick up bounce light from static objects using Light Probes. Light Probes are positions in the scene where the light is measured (probed) during the bake/precomputation, and then at runtime the indirect light that hits non-static objects is approximated using the values from the probes that the object is closest to at any given moment. So for example a red ball that rolls up next to a white wall would not bleed its color onto the wall, but a white ball next to a red wall could pick up a red color bleed from the wall via the light probes.
烤焙GI和预计算的实时GI都有限制,只有静态对象可以包含在烤焙/预计算中——所以移动的对象不能将光反射到其他物体上,反之亦然。然而,他们仍然可以使用光探测器从静态物体中获取反射光线。光探测是在烤焙/预计算期间测量(探测)光的场景中的位置,然后在运行时,对非静态对象的间接光线通过在任何给定时刻与对象最接近的探针的值进行近似。举个例子,一个在白色墙壁旁边滚动的红球不会把它的颜色融合到墙上,但是在红色的墙上的一个白色的球可以通过光探测器从墙上取下一个红色的血。

Examples of GI effects

  • Changing the direction and color of a directional light to simulate the effect of the sun moving across the sky. By modifying the skybox along with the directional light it is possible to create a realistic time-of-day effect that is updated at runtime. (In fact the new built-in procedural skybox makes it easy to do this).改变平行光的方向和颜色,以模拟太阳在天空中移动的效果。通过修改天空盒和平行光,可以创建一个写实的时间日效果,在运行时更新。(事实上,新的内置程序化天空盒使得这样做很容易)。
  • As the day progresses the sunlight streaming in through a window moves across the floor, and this light is realistically bounced around the room and onto the ceiling. When the sunlight reaches a red sofa, the red light is bounced onto the wall behind it. Changing the color of the sofa from red to green will result in the color bleed on the wall behind it turning from red to green too.随着时间的推移,阳光从窗口穿过地板,穿过地板,这束光实际上在房间里和天花板上反射。当阳光照射到红色的沙发上时,红光就会被弹回到后面的墙上。将沙发的颜色从红色变为绿色会导致墙壁上的颜色融合,也会从红色变为绿色。
  • Animating the emissiveness of a neon sign’s material so it starts glowing onto its surroundings when it is turned on.使霓虹灯的材料的自发光变得生动,当它被打开时,它就会开始向周围的环境发光。

猜你喜欢

转载自blog.csdn.net/cangod/article/details/80706981