Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Unity3D 5.0 + dynamic loading Model and corresponding Light Map method

2025-02-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Unity3D 5.0 + dynamic loading model and the corresponding Light Map method example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

The premise is necessary:

1. A static model with Mesh Renderer is required.

2. Need to have Light Map in accordance with the model.

3. Close Auto Build in Lighting

Procedure:

1. Import Light Map and modify the format

2. Use scripts to load imported Light Map to Light Map Settings for the scene

2.1. Light Map cannot be loaded directly into Light Map Settings, so you need to create an Light Map Data array in the script to store all the Light Map needed in the current state of the scene and assign it to Light Map Settings

Example script:

/ / Light Map array

Texture2D [] DayNear;Texture2D [] DayFar

/ / Light Map Data array

LightmapData [] dayLightMaps

/ / add LightMap to the LightMap Data array

DayLightMaps = new LightmapData [DayNear.Length]

For (int item0; I {

DayLightMaps [I] = new LightmapData ()

DayLightMaps [I] .lightmapNear = DayNear [I]

DayLightMaps [I] .lightmapFar = DayFar [I]

}

/ / change the current scene Light Map status

LightmapSettings.lightmaps = dayLightMaps

2.2.2.The order of Light Map in Light Map Data will affect Light Map Index, so it is best to add automatic sorting command. If not, manual sorting is required.

Example script:

Using System.Linq

DayNear = DayNear.OrderBy (T2d = > t2d.name, new NaturalSortComparer ()) .ToArray ()

2.3.The Light Map is divided into two types (lightmapNear and lightmapFar). If there is only one Light Map, you need to paste it on both types at the same time.

3. Specify a static model through Light Map Index and use a Light Map number to query it in Lightmaps in Lighting.

Example script:

Transform.GetComponent () .lightmapIndex = 0

Light Map Index is shown in the figure:

Note:

1. Light Map cannot be called by Light Map Settings alone and needs to be replaced. It must be stored in Light Map Data and assigned to Light Map Settings.

2. When a single static model needs to be called dynamically, if the current Light Map Settings

If you already have the Light Map used in it, you only need to specify the Light Map Index to replace the Light Map Settings.

Thank you for reading this article carefully. I hope the article "Unity3D 5.0 + dynamic loading Model and sample Analysis of corresponding Light Map methods" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report