光源类型
World Light世界光源(World Light)#
World Light is an infinitely remote light source casting orthographically projected beams onto the scene. The shadows cast by this light are parallel, which provides a realistic simulation of celestial bodies such as the Sun and Moon. World Light also takes part in simulation of atmospheric scattering.世界光源是无限远距离光源,向场景投射正交投影光束。其产生的阴影呈平行状,可逼真模拟太阳/月亮等天体效果。该光源还参与大气散射模拟。
Omni Light全向光源(Omni Light)#
Omni Light is a point source emitting light in all directions and realistically reproducing cast shadows. This type of light serves to simulate light sources with bright center and equal roll-off of intensity. Omni Light proves useful for general lighting purposes in indoor scenes because of its nondirectional qualities. In addition, Omni Light has many shapes and therefore can be used to create a variety of lights for indoor and outdoor lighting.全向光源是向所有方向发射光线的点光源,能真实产生投射阴影。这类光源适合模拟具有明亮中心且强度均匀衰减的光源。因其无方向性特性,特别适合室内场景的基础照明。此外,全向光源支持多种形状设定,可用于创建各类室内外灯光效果。
Projected Light投射光源(Projected Light)#
Projected Light is a light source that casts light from a single point forming a focused beam aimed in a specific direction. This type of light is visualized in a form of a pyramid. Due to its form, it is versatile and can be conveniently used to simulate the numerous light emitting sources: for example, car headlights, flash light, or street lamps.投射光源是从单点发射形成定向聚焦光束的光源。其光锥呈金字塔形态,可灵活模拟多种发光体:如汽车前灯、手电筒或路灯等。
Area Lights区域光源(Area Lights)#
By default, Omni and Projected light sources are represented by a point emitting light. They both also have additional parameters that specify the light shape (sphere, capsule or box). Local light sources provide wider light spots and correct specular highlights on geometry. 默认情况下,全向光源和投射光源都表现为点光源形式。它们还具有指定光源形状(球体/胶囊体/立方体)的附加参数。局部光源能产生更宽广的光斑效果,并在几何体上形成精确的高光。
Emissive Objects自发光物体(Emissive Objects)#
It is also possible to make almost any geometry emit light (e.g. to make neon signs or a glowing electric stove). This is done using Emission, and materials have a corresponding set of parameters that allow you to set the glow brightness and color. By default, the glow from such objects does not affect the environment. However, it is possible to bake lighting from an emissive object to GI (we'll review this in detail a bit later) or calculate it in real time with Screen-Space GI.几乎任何几何体都可设为发光体(如霓虹灯或电炉灶)。通过材质的自发光(Emission)参数组,可设置辉光亮度与颜色。默认这类发光不影响环境光照,但可通过烘焙至GI(后续详解)或使用屏幕空间全局光照(Screen-Space GI)进行实时计算。
How Shadows Are Drawn and Why Too Many Sources May Cause Performance Drop阴影绘制原理与多光源性能问题#
Now we know what types of light sources are available and we want to hang the Sun (World Light) outside the window, light the room with a lot of spotlights (Projected Light), and a lot of bulbs (Omni Light), or even a garland! But, it is said that a large number of light sources can be very hard on performance, and shadows are the culprit! To understand why regular shadows are so expensive, we need to understand how they are drawn.现在我们已经了解各类光源,可能想要在窗外挂上太阳(世界光源),用大量射灯(投射光源)和灯泡(全向光源)照亮房间,甚至布置灯串!但据说大量光源会严重影响性能,而阴影正是罪魁祸首!要理解常规阴影为何如此消耗资源,需先了解其绘制原理。
Shadows in engines (and UNIGINE is no exception here) are drawn using the traditional Shadow Mapping method, which allows you to define lighted and darkened areas for each light source. This method is based on the use of Z-buffer (depth buffer). First, we draw the scene into the Z-buffer from the point of view of the light source to define the pixels visible from this point and the distances to them — thus a special buffer (shadow map) is created, which is a two-dimensional texture. Then, when the scene is drawn from the observer's point of view, the texture coordinates are compared with the shadow map: if this comparison says that the corresponding pixel is invisible from the point of view of the light source and therefore should be shaded, it is painted with a dark color.引擎中的阴影(包括UNIGINE)采用传统的阴影映射(Shadow Mapping)技术绘制,该方法可为每个光源定义受光与阴影区域。其原理基于Z缓冲(深度缓冲)的使用:首先从光源视角将场景绘制到Z缓冲,确定该视角可见像素及其距离——从而生成特殊的二维纹理阴影贴图(shadow map)。接着从观察者视角渲染场景时,将纹理坐标与阴影贴图比对:若比对结果显示某像素在光源视角不可见则应处于阴影中,该像素就会被渲染为暗色。
This is how it's done for a directional Projected source, but if we have an Omni point source (an ordinary light bulb, for example), then instead of one depth buffer we have to draw a whole cube map (6 depth buffers, one for each side of the cube surrounding the light source). Thus, one bulb requires drawing the scene again, albeit highly simplified, but 6 more times! And this all is for one frame! Now it becomes clear why a large number of light sources significantly increases the load on the GPU, so all sorts of tricks are used to minimize the number of sources for which shadows are actually calculated. Depending on the scene type, different approaches are used.上述是定向投射光源的处理方式,但对于全向点光源(如普通灯泡),则需要绘制立方体贴图(6个深度缓冲,对应光源周围立方体的每个面)来替代单一深度缓冲。这意味着一个灯泡就需额外绘制6次简化版场景!而这仅针对单帧画面!现在就能理解为何大量光源会显著增加GPU负载,因此需要采用各种技巧来最小化实际计算阴影的光源数量。根据场景类型,可采用不同优化方案。
本页面上的信息适用于 UNIGINE 2.20 SDK.