光照贴图可以使用两种__定向模式__:__定向 (Directional)__ 和__非定向 (Non-Directional)。要为光照贴图设置__定向模式 (Directional Mode),请打开 Lighting 窗口 (Window > Lighting > Settings),单击 Scene__,导航到 Lightmapping Settings__,确保 Lightmapper 设置为 Enlighten__,然后使用 Directional Mode__ 下拉菜单。这两种模式可以以实时和烘焙光照贴图形式提供。
__定向__光照贴图存储的有关光照环境的信息量要多于__非定向__光照贴图。着色器可以使用这些关于入射光的额外数据来更好地计算出射光,也就是材质在屏幕上呈现的外观。此过程的代价是增加了纹理内存使用量和着色时间。
__非定向__:平面漫射。此模式仅使用单个光照贴图,存储有关表面发光量的信息,同时假设表面是纯漫射的。以这种方式照射的对象将显示为平面(不会使用法线贴图)和漫射(即使材质是高光),但除此之外,将获得正确光照。这些木桶现在使用了烘焙光照贴图。唯一的细节定义来自于反射探针和遮挡贴图。
__定向__:法线贴图漫射。此模式会添加辅助光照贴图,可存储入射主导光方向以及一个系数。系数与第一张光照贴图中主导光同方向的光的数量成比例。然后,假定其余光均匀来自整个半球。该信息允许材质进行法线贴图,但仍显示为纯漫射。
__定向__模式使用的纹理内存量是__非定向__模式的两倍,因此着色成本略高。
__非定向:__一个纹理、一次纹理采样、一些额外的着色器指令。
__定向:__两个纹理、两次纹理采样、更多一些的额外着色器指令。
实时光照贴图利用相同的方法,并受制于相同的着色质量/成本权衡。
实际用于间接光(烘焙的间接部分)的 BRDF 是成本略低的版本。UNITY_BRDF_PBS_LIGHTMAP_INDIRECT
在 UnityPBSLighting.cginc 中进行定义。
要在光照贴图静态资源中实现镜面光照,请对烘焙光源使用光源模式 Shadowmask 或 Distance Shadowmask。这可以确保光照兼具实时和高质量。请参阅有关光源模式的文档以了解更多信息。
2017–06–08 页面已发布
在 5.6 版中删除了“直接镜面反射”(Direct Specular)
在 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.