Subtractive 模式是由场景中所有混合光源共用的一种光照模式。要将 Mixed lighting 设置为 Subtractive__,请打开 Lighting 窗口(菜单:__Window > Rendering > Lighting Settings__),单击 Scene__ 选项卡,导航至 Mixed Lighting__,然后将 Lighting Mode__ 设置为 Subtractive。请参阅混合光照相关文档以了解有关此光照模式的更多信息,并参阅光照模式相关文档以了解有关其他可用模式的更多信息。
Subtractive 是唯一将直接光照烘焙到光照贴图中并丢弃 Unity 用于在其他混合光照模式下合成动态和静态阴影的信息的混合光照模式。由于光照已烘焙到光照贴图中,因此 Unity 无法在运行时执行任何直接光照计算。
在 Subtractive 模式下:
静态游戏对象根本不显示混合光源中的任何镜面高光或光泽高光。除了主方向光,它们也不能接受动态游戏对象投射的任何阴影(有关此内容的更多信息,请参阅下面的段落)。
动态游戏对象接受实时阴影并支持光泽反射。但是,它们只能通过光照探针接受静态游戏对象投射的阴影。
在 Subtractive 模式下,主方向光(通常为太阳)是唯一将动态游戏对象的实时阴影投射到静态游戏对象上的光源。从静态游戏对象投射到其他静态游戏对象的阴影将烘焙到光照贴图中,即使对于主光源也是如此,因此 Unity 无法保证烘焙阴影和实时阴影的正确合成。因此,__Subtractive__ 模式有一个 Realtime Shadow Color 字段。Unity 在着色器中使用此颜色将实时阴影与烘焙阴影进行合成。为此,它会减少光照贴图在动态游戏对象投射的阴影区域中的效果。因为引擎不能预先确定正确值,所以如何选择适用于给定场景的值取决于您自己的审美选择。
适合使用 Subtractive 模式的一个很好的例子是,您想要构建一个具有室外关卡和极少数动态游戏对象的卡通风格 (cel-shaded) 游戏。
下表显示了使用 Subtractive 模式时静态和动态游戏对象如何投射和接受阴影:
动态阴影接受者 从另一个静态或动态游戏对象接受阴影的动态游戏对象 |
静态阴影接受者 从另一个静态或动态游戏对象接受阴影的静态游戏对象 |
|||
---|---|---|---|---|
在阴影距离内 | 超出阴影距离 | 在阴影距离内 | 超出阴影距离 | |
动态阴影投射物 投射阴影的动态游戏对象 |
阴影贴图 | - | 主光源阴影贴图 | - |
静态阴影投射物 投射阴影的静态游戏对象 |
光照探针 | 光照探针 | 光照贴图 | 光照贴图 |
鉴于 Subtractive 模式的性能要求,该模式非常适合以低端移动设备为目标的构建。Subtractive 模式最主要的优缺点如下:
在光照贴图中的静态游戏对象之间提供高质量阴影,无需额外的性能要求。
着色器中的一个纹理操作即可处理静态游戏对象之间的所有光照和阴影。
提供间接光照。
不提供实时直接光照,因此不提供镜面反射光照。
除了一个方向光(主光源)外,不会在静态游戏对象上提供动态阴影。
仅通过光照探针提供从静态游戏对象到动态游戏对象上的低分辨率阴影。
提供不准确的动态和静态阴影合成。
增加了光照贴图纹理集的内存要求(与无光照贴图的情况下相比)。
2017–06–08 页面已发布并只进行了有限的编辑审查
在 5.6 版中添加了“光照模式”
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.