Unity3d Optimization Summary

Source: Internet
Author: User
There are many optimizations for the project, such as mesh merging, reducing drawcall and model bones and physical calculations, merging material balls, optimizing code, etc.
Previous post "finishing" Unity 3d optimization Summary
Now continue to fill in, the content for my experience and online collection and collation, I hope we have a better way to optimize, can continue to thread, together to explore, common progress.

Optimization:

1. Update the opacity map compression format for etc 4bit, because the Android market in the mobile phone GPU has a variety of
Each GPU supports different compression formats, but they are compatible with the ETC format,

2. For transparent mapping, we can only select Rgba 16bit or Rgba 32bit.

3. Reduced FPS, in projectsetting-> quality
VSync the Count parameter will affect your fps,everyvblank equivalent to Fps=60,everysecondvblank = 30;
Both of these situations do not match the game FPS, we need to manually adjust the FPS, first turn off the vertical synchronization of this function, and then in the code of the Awake method manually set fps (application.targetframerate = 45;)
Benefits of reduced FPS:
1) Save electricity, reduce the situation of mobile phone fever;
2) can stabilize the game fps, reduce the situation of lag.

4. When we have set FPS, then adjust the fixed timestep this parameter,
This parameter, in Projectsetting->time, is designed to reduce the number of physical computations to improve game performance.

5. Use the update lateupdate fixedupdate as little as possible to improve performance and conserve power.
Multi-use events (not SendMessage, using your own writing, or event delegates in C #).

6. When standby, adjust the game's FPS to 1, saving power.

7. The size of the atlas is best not higher than 1024, or the game after installation, low-end computer crashes directly, because the mobile phone system version is less than 2.2, more than 1000 of the atlas can not read, caused.
More than 2.2 did not meet this condition.
Note that the phone's RAM and ROM, less than 512M of mobile phones, the direct waiver model adaptation.

Vscount Vertical Synchronization
Unity3d a new scene is empty, the frame rate (FPS is always very low), probably between 60~70.
Have not quite understood what is going on, now basically understand. I am here to explain why, if there is a mistake, please correct me.
In Unity3d when the runtime opens the profiler, we see that VSync is a big part of this.
What is this, this is vertical synchronization, to explain later.
We can turn off vsync to increase the frame rate and select Edit->project settings->quality.


You can find VSync Count in the right panel and select it as Don ' t Sync.

This turns off the VSync (vertical sync) and now, in the run scenario, see if the frame rate is much higher.

Now to say what is vertical synchronization, to know what is vertical synchronization, you must first understand how the display works,
All images on the display are scanned on a first-line basis, whether interlaced or progressive,
The display has two synchronization parameters-horizontal and vertical synchronization.

What is called horizontal synchronization. What do you mean vertical synchronization.
Vertical and horizontal are the two basic synchronous signals in the CRT, and the horizontal synchronous signal determines the time that the CRT draws a cross-screen line,
The vertical sync signal determines when the CRT draws from the top of the screen to the bottom and then returns to the original position.
But the vertical synchronization represents the level of the refresh rate of the CRT display.

Why turning off the vertical sync signal will affect the FPS value in the game.
If we choose to wait for the vertical sync signal (which is what we normally call Vertical sync open),
Then in the game maybe a strong graphics card quickly finished drawing a screen image, but there is no vertical synchronization of the arrival of the signal,
The video card cannot draw the next screen, only 85 units of the signal arrives, can be drawn.
This way FPS is naturally subject to operating system refresh rate running value.

And if we choose not to wait for the vertical sync signal (which is what we normally call the vertical sync off), then the game is finished with a screen,
Graphics cards and monitors do not need to wait for a vertical sync signal to start the next screen image painting, naturally can fully play the power of the graphics card.
But do not forget that it is because of the existence of vertical synchronization in order to make the game process and display refresh rate synchronization, making the picture more smooth and stable.
Cancellation of the vertical synchronization signal, although it can be replaced faster, but the continuity of the image is bound to be discounted.
This is why many friends complain about the theoretical reason that the screen is discontinuous after vertical closure.

Merge Material Ball Unity 3d every time you pour a model more than one material ball, but my models are shared with a map of the want to share a material ball, so every time to remove the attached, very troublesome. How to merge these material balls.
Use texturepacking Bar
1, traverse gameobject, remove material, and according to shader to material classification
2. Call Unity's packtextures function to combine the textures of material in each shader class (Packtextures function is defective, but can be used)
3, according to the combined large texture to update the original model texture, material has UV coordinate values.

It is important to note that the texture that needs to be merged should be close to the object in the scene, if the object is farther away in the scene,
It is not recommended to merge textures, as this is likely to be less than optimal, but less efficient.

Mesh Merge
2 Ways to merge
1. Your own merge must be checked for static.

All gameobject with "Static" selected, the mesh in the mesh filter will be merged into "Combined Mesha (Root:scene)"


2. You can also use a script to merge mesh.
[C #] Plain text view copy code?

01 02 03 04 05 06 07 08 09

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.