Unity 会根据您加载或卸载场景的方式而以不同方式更新其光照探针数据。
Unity 使用 LightProbes C# 对象为所有当前加载的场景存储光照探针数据。LightProbes
对象包含一个内部数据结构,称为四面体曲面细分。Unity 在其计算中使用四面体曲面细分来确定光照探针照亮游戏对象的方式。
加载或卸载场景时,Unity 会自动更新 LightProbes
对象,以包含所有当前加载的场景中所有光照探针的位置和系数。但是,Unity 是否更新四面体曲面细分取决于加载或卸载场景的方式。
When you load a Scene with LoadSceneMode.Single, Unity updates the tetrahedral tessellation automatically as part of the load process, because the new light probe data completely replaces the previous light probe data.
When you load a Scene with LoadSceneMode.Additive, or unload a Scene with UnloadSceneAsync, Unity does not automatically update the tetrahedral tessellation, because the new or removed light probe data needs to be recalculated - which is a computationally expensive operation, and there may be subsequent scenes to be loaded or unloaded after this operation.
Therefore Unity provides you with the needsRetetrahedralization event to allow you to decide when to retetrahedralize the new light probe data. For example, if you are additively loading five new scenes, you would not want to retetrahedralize the data five times, once after each scene loads. Instead, you would only want to retetrahedralize the data after all five scenes have loaded and all the new light probe data is ready.
如果 Unity 使用过时的四面体曲面细分来执行计算,则结果将不会考虑任何新加载或卸载的光照探针。这意味着光照探针可能无法按预期照亮游戏对象,而且对 LightProbes.CalculateInterpolatedLightAndOcclusionProbes() 或 LightProbes.GetInterpolatedProbe() 的调用可能会返回意外结果。
要强制 Unity 更新四面体曲面细分,可以调用 LightProbes.Tetrahedralize 或 LightProbes.TetrahedralizeAsync()。这些函数使 Unity 使用所有当前加载的场景的所有光照探针中的数据来更新四面体曲面细分。
更新四面体曲面细分是一项 CPU 密集型操作,并且随着光照探针数量的增加,CPU 的负载也会增加。如果要加载和卸载多个场景,并且由于更新四面体细分而对性能产生了影响,那么最好是延迟更新:等到加载或卸载了一定量的内容或者等到 CPU 负载不太可能影响应用程序性能时,再进行更新。
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.