混合__光源是 Mode__ 属性设置为 Mixed 的光源组件。
__混合__光源可在运行时更改其变换和视觉属性(例如颜色或强度),但仅限于严格的限制范围内。它们同时照亮静态和动态游戏对象,总是提供直接光照,也可选择提供间接光照。接受__混合__光源光照的动态游戏对象总是在其他动态游戏对象上投射实时阴影。
场景中的所有__混合__光源都使用相同的__混合____光照模式。要设置__光照模式 (Lighting Mode),请打开 Lighting 窗口(菜单:__Window__ > Lighting__),单击 Scene__ 选项卡,然后导航至 Mixed Lighting 部分。
可用模式有:
混合光照对于不属于游戏但可照亮静态环境的光源(例如天空中不动的太阳)非常有用。混合光源的直接光照仍需在运行时计算,因此静态网格上的材质将保持其视觉保真度,包括完整的基于物理着色 (PBS) 支持。
Distance Shadowmask is the most resource-intensive option, but provides the best results: it yields high-quality shadows within the Shadow Distance (Edit > Project Settings > Quality > Shadows), and baked high-quality shadows beyond. For example, you could create large landscapes with realistic shadows right up to the horizon, as long as the sun does not travel across the sky.
Subtractive 模式提供最低质量的结果:仅为一个光源实时渲染阴影,并将阴影与烘焙的直接和间接光照进行合成。只有目标平台无法使用任何其他模式时(例如,应用程序需要在低端移动设备上运行,但内存限制会阻止使用 Shadowmask 和 Distance Shadowmask 模式)才应使用此模式作为后备解决方案。
请参阅 Unity 光照模式参考卡 (Unity Lighting Modes Reference Card) 了解各种模式的集中比较。
所有平台都支持所有混合光照模式。但是,有一些渲染限制:
Subtractive 模式会回退到前向渲染(无延迟或光照 prepass 支持)。
Shadowmask and Distance Shadowmask modes fall back to forward rendering(RenderTech-ForwardRendering) (no deferred or light prepass support) on platforms which only support four render targets, such as DirectX 9.
请参阅渲染通道相关文档以了解有关前向渲染和延迟渲染的更多信息。
__混合__光源可在运行时更改其变换和视觉属性(例如颜色或强度),但仅限于严格的限制范围内。实际上,由于某些光照是烘焙的(因此是预先计算的),在运行时更改任何参数都会导致在组合实时光照和预计算光照时出现不一致的结果。
In the case of Baked Indirect, Shadowmask and Distance Shadowmask, the direct lighting contribution behaves just like a Realtime Light, so you can change parameters like the color, intensity and even the Transform of the Light. However, baked values are precomputed, and cannot change at run time.
例如:如果将红色__混合__光源烘焙到光照贴图中,但在运行时将其颜色从红色变为绿色,则所有直接光照都会切换为绿色。但是,所有间接光照都被烘焙到光照贴图中,因此它仍然是红色的。此情况同样适用于在运行时移动混合光源:直接光照将跟随光源,但间接光照将保持在光源烘焙位置。
If only subtle changes are introduced to direct lighting (for example, by only slightly modifying the hue or intensity of a Light), it is possible to get the benefits of indirect lighting and for the Light to appear somewhat dynamic, without the extra processing time required for a Realtime Light. Indirect lighting is still incorrect, but the error might be subtle enough not to be objectionable. This works especially well for Lig hts without precomputed shadow information. This is achieved either by having shadows disabled for the Light, or by using Baked Indirect mode where shadows are real time. As shadowmasks are part of the direct lighting computation, moving such Lights causes visual inconsistencies with shadows not lining up correctly.
以下视频举例说明了当混合光源移动到离开烘焙位置太远时会发生的情况。请注意,尽管对象移动很远,墙壁上的红色间接光仍保持原位:https://youtu.be/o6pVBqrj8-s
以下视频举例说明了如何略微修改混合光源而不会导致间接光照出现明显不一致问题:https://youtu.be/XN6ya31gm1I
In the case of Mixed Lights, the last segment of a light path (that is, the path from the Light to the surface) becomes part of the precomputation as well. However, Unity still handles direct lighting and indirect lighting separately. It bakes indirect lighting into light maps and Light Probes, which are then sampled at run time. Indirect lighting is generally low frequency, meaning it looks looks smooth and doesn’t contain detailed shadows or light transitions. Therefore, shadows are handled with direct lighting where they have a high visible impact.
预计算和存储阴影的方式的差异反映在混合光源的各种子模式中:
阴影信息可预计算并存储在阴影遮罩中。阴影遮罩是一种纹理,它与相应的光照贴图共享相同的 UV 布局和分辨率。它存储每个纹理像素的最多四个光源的遮挡信息(因为纹理在当前 GPU 上限制为最多四个通道)。值的范围是 0 到 1,中间的值标记柔和阴影区域。
If shadowmasks are enabled, Light Probes also store occlusion information for up to four Lights. If more than four Lights intersect, the excess Lights fall back to Baked Lights. You can inspect this behavior with the shadowmask overlap visualization mode. This information is precomputed, so only the only shadows Unity stores in the shadowmask are shadows cast from static GameObjects onto other static GameObjects. These shadows can have smoother edges providing better quality than real-time shadow maps, depending on the light map resolution. Because each Mixed Light retains its shadowmask channel mapping at run time, shadows cast by dynamic GameObjects via shadow maps can be correctly composited with precomputed shadows from static GameObjects, avoiding inconsistencies like double shadowing.
静态游戏对象的阴影与动态游戏对象的阴影之间唯一可察觉的差异是预计算的阴影遮罩与运行时阴影贴图的分辨率和过滤差异,此外,预计算的阴影支持各种形式的面光源,因此柔和阴影可能具有更逼真的半影。
What all Mixed modes except for Subtractive mode have in common is that direct lighting is always computed in real time and added to the indirect lighting stored in the light map, so all Material effects that require a light direction continue to work. Dynamic GameObjects always cast shadows on other dynamic GameObjects via shadow maps within the Shadow Distance (Edit > Project Settings > Quality > Shadows), if shadows are enabled for that Light.
2017–06–08 Page published with limited editorial review - Leave page feedback
在 5.6 版中添加了“光照模式”