Unity scene art resource optimization

1. Model

① Area reduction: Area reduction and optimization of the scene model is the most common optimization operation. The main thing is to remove the faces that have no effect on the model shape, and use as few faces as possible to clearly express the structure and shape of the model. For example: the non-joint points of the object and the back surface of the object and the surfaces that cannot be seen inside are deleted. 

②Merge model: Merge non-interactive static widgets in the same small range, and merge the textures of the widgets at the same time. This reduces the number of DRAW CALLs. For example, a group of grasses of different sizes, a group of stones of different sizes and shapes, a bookshelf and many books placed on it, etc. Combine these small objects into an object, and the textures are also synthesized into a texture. On high-end mobile phone platforms, draw calls are generally controlled at around 300.

③LOD: Buildings and complex objects use LOD models and distant culling to reduce the number of screens on the same screen. The LOD system of the terrain can also greatly optimize the number of terrain faces.

④Reuse of the model: The same multiple objects are copied and used in Unity, and the copied multiple objects are counted as one object in the engine calculation. But don't copy too many, too much will put a lot of pressure on the memory. There are too many identical objects. It is recommended to combine several into one group as one Object, make several more groups, and then copy them. Refer to ②.

 

⑤ Terrain optimization: If the terrain is made with the terrain tool that comes with Unity, it can be converted into T4M format terrain with the T4M plug-in. After setting a vertex value conversion, the terrain can be optimized a lot. T4M can also set lod models.

 

Take a test I have done as an example: Before optimization, the terrain is 1000*1000. That is (1000-1)*(1000-1)=998001 (surfaces), nearly 1 million surfaces. The transformed vertex value is set to 100, and the transformed face is 19602, which is only nearly 20,000 faces.

2. Material map

① Texture size: The maximum size of the texture on the mobile device should be controlled at 1024 and 512 size, and a small amount of 2048 size texture can be used, mainly 1024 and 512 size texture.

 

②Use of repeated textures: Use 1-3 textures to cover a large area of ​​the same material alternately and repeatedly, breaking the sense of repetition of textures through changes in light and shadow.

③ The textures of small objects are merged. As mentioned above, the texture of a single object is preferably one, and it is not easy to exceed three at most. Shaders with the same texture are unified.

 

④ Use less transparent textures, don't use them if you can. Transparency maps are very GPU intensive.

 

⑤Support Mipmap, Mipmap will increase the size of the game package and occupy a certain amount of memory, but the rendering of Mipmap in the game can reduce the memory bandwidth and reduce the rendering pressure. Consideration, thereby saving resource expenditure. Excessive use of mipmaps will put a lot of pressure on memory, so it is recommended to only set mipmaps for large objects.   

(Unity will generate 8 textures with gradually decreasing pixels according to the camera distance from near to far, only 5 are intercepted here, from left to right are the original image to the low-pixel texture generated by Mipmap)

 

⑥ PBR materials can be used for small scenes, and real-time lighting must be used for PBR materials to be effective. Avoid using PBR materials in large scenes, and use baked light and shadow as much as possible to achieve lighting effects in large scenes. For the baked scene model, do not use the normal map, it will have no effect if it is pasted, and it also takes up space resources.

⑦ Texture compression, compressing textures in PVRT (Ios) or ETC (Android) format can reduce a lot of memory consumption.

        

⑧ It is suggested that the material of the scene can be converted into .sbsar format material using the substance material system. Substance materials can greatly compress the size of texture data without losing texture quality.

        

As shown in the figure below: 33.8MB of .tga format textures are only 3.8MB after they are made into .Sbsar format materials.

 

3. Lighting   

1. The number of lights: It is recommended to use only one parallel light for large outdoor open scenes. The indoor scene can be a little more appropriate, and the reflection probe can be used in the indoor environment to enhance the reflection effect.

 

2. Scene baking: Large scenes and more complex indoor scenes should avoid the use of real-time lighting. Use UNITY's baking system to bake light and shadow into maps to achieve light and shadow effects. Baking the map itself is a huge project, and the baking of large scenes can be selectively baked. The automatic UV division function in UNITY is not easy to control, so generally, the second set of UVs is divided in max\Maya, or you can directly bake the lightmap in max\Maya and import it into unity.

 

UNITY provides mixed mode lights, so we can use mixed lights to combine LIGHTMAP with real-time lights. Both: In a large scene, large objects such as buildings and terrain occupy larger objects on the screen to bake lightmaps, and there are many small objects that occupy a small area of ​​the screen, so there is no need to bake them, and the lights are set to mixed mode.

4. Other

①Use less lens effects on the camera and use them selectively.

②Use special Shader with caution.

 

③The optimization of art resources can be considered from the earliest setting of the scene. For example, the level of an ARPG game can be set to a fully open outdoor scene if it can use a pipeline scene according to the situation.

(This is the scene and map of Legend of Sword and Fairy 5. According to the needs of the plot, focus on making the scenes on both sides of the path, and use obstacles to block other places so that players cannot pass, so I can summarize and simplify the explanation.)  

 

④ Games that are mainly played on land should avoid designing designs that fly into the air. Looking down on the scene in the near sky is very resource-intensive.

     

⑤ In the design of large open scenes, it is necessary to avoid too many destructible objects, and the points that can be interacted in the scene should be clear, avoid large and comprehensive designs, and pay attention to trade-offs.

(This is also a small town scene in Legend of Sword and Fairy. The interactive points are very clear. The interaction of other building NPCs can simplify the production or do not interact.)

 

The data for a scenario optimization test I have done is as follows:

Before optimization:

1. This scene uses UNITY's own terrain. There are a lot of vegetation and grass on it, and more than 30 abandoned buildings. There are a lot of vegetation and weeds, waste paper, wine bottles, stones, etc. on the ground and buildings. There are about 10 streets in both horizontal and vertical sizes. There are a lot of street lights, street signs, oil drums and other details on the street.

2. The scene itself uses the LOD system.

3. The total number of faces is more than 2 million. Small objects in more than 15,000.

The number of frames running on the PC is only more than 40 frames. On the 835 chip mobile phone, the screen is seriously stuck, and the frame is skipped seriously.

Optimization:

1. Convert the terrain into T4M format with T4M plug-in, and reduce the trees and vegetation in the distance on a large scale. Optimized and improved by about 5 frames.

2. The small objects on the street were deleted and merged. There were too many small objects on the interface in the original scene, and the street lights were too dense. Appropriate deletions were made, and the models and textures of the small object models in a small range were merged. About 7 frames higher

3. The reduction of transparent textures. The original scene was a ruin, so a lot of transparent title maps were used to make vines in the building, which was too expensive for rendering, so it was moderately deleted, about half of it was deleted, and about 10 frames were increased.

4. Lightmap baking is performed on buildings, streets, large terrain and large objects. Small objects are illuminated in real time with the blending mode of the lights. About 30 frames higher

5. Reduce the lens effects in the original scene. In the original scene, 7 lens effects were used, and the three lens effects of Antialiasing As Post Effect, Vignetting, and SSAO were turned off. These three effects had little effect on the picture, and they increased by about 10 frames.

The final optimization back number is more than 700,000 faces. FPS is around 100 frames.

Summarize:

The optimization of art scene resources mainly starts from the aspects of models, textures, lighting, special effects, etc., which corresponds to improving the utilization efficiency of hardware such as CPU, GPU, and memory. There are still many optimization details. For example, the scene effects can be implemented with animation as much as possible, avoiding too many particle effects, and the colliders of the scene are modeled separately instead of the default colliders of Unity. The post-stage optimization of a game is multi-faceted, including scenes, characters, actions, special effects, sound effects, animations, AI and procedural operations, etc. If you can optimize the scene a little more, you can make room for other resources.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325482791&siteId=291194637