"Unity optimization" finishing on optimization

Source: Internet
Author: User

0. If you do an atlas is 1024x1024. At this point in your interface only use a small picture in the atlas, then I'm sorry 1024x1024 this large map needs to be loaded into your memory, 1024 is 4M of memory, if you do 10 1024 of the atlas, your interface is just a small map of each atlas, Then again sorry your memory directly 40M. It means any 4096 picture, whether it is atlas or texture, he occupies 4*4=16m.

1. Vertex performance
In general, if you want to render no more than 40,000 visible points per frame on iphone 3GS or newer devices,
So for some older devices with MBX GPUs (for example, the original iphone, such as the iphone 3g and IPod Touch 1th and 2nd generation), you should make sure that the render vertices of each frame are below 10000.
2. Light Performance
The dynamic illumination of a pixel adds significant computational overhead to each affected pixel and may cause the object to be rendered multiple times.
To avoid this situation, you should avoid using multiple pixel illumination for any single object and use directional light wherever possible.
It is important to note that the pixel light source is a light source that is set to be critical (Important) in a render mode.
The dynamic illumination of a pixel adds significant overhead to the vertex transformation. Therefore, you should try to avoid any given object being illuminated by multiple light sources at the same time.
For static objects, it is a more effective method to use baked light.
3. Role
Each role uses a skinned mesh Renderer as much as possible, because when the role has only one skinned mesh Renderer,
Unity uses the method of visibility clipping and bounding body updates to optimize the motion of the character, which is only started when the role contains only one skinned Mesh renderer.
The role of the number of polygons generally do not exceed 1500, the number of bones less than 30, the number of characters material is generally the best.
4. Static objects
For static objects, the number of fixed points requires less than the range of 500,UV (0,1), which is useful for flattening optimization of textures.
Do not attach the animation component to a static object, although adding has no effect on the result, but increases the CPU overhead.
5. Camera
Set the far plane to the right distance, far from the plane the Assembly will add some unnecessary objects to render, reducing the efficiency.
In addition, we can set the far cutting plane of the camera according to different objects. Unity provides the ability to set different view distance depending on the layer,
So we can achieve the layering of objects, large object layer set the visible distance, and the small object layer can be set to smaller,
In addition, some of the more expensive entities (such as particle systems) can be set smaller and so on.
6, Drawcall
As much as possible to reduce the number of drawcall. No more than 100 recommended on IOS devices.
The main methods of reduction are as follows: Frustum culling, occlusion culling, Texture Packing. Frustum culling is built within Unity, what we need to do is to find a suitable far cutting plane;
Occlusion culling, occlusion culling, Unity embedded Umbra, a very good OC library.
But occlusion culling is not universal, sometimes it is slower than not to do OC,
It is recommended to determine whether your scene is suitable for OC optimization before OC, Texture Packing, or Texture atlasing,
is to flatten the same shader texture to reduce draw call based on Unity's static batching characteristics.
Suggested use, but also has the disadvantage, that is must be the scene in the distance similar solid texture to flatten, otherwise, will probably increase each frame to render the texture size,
Increase the burden of memory bandwidth. This is why there will be "drawcall down, rendering speed has slowed down" reason.

7.1. The particle system runs slowly on the iphone, what to do.
Answer: The iphone has a relatively low fillrate.
If your particle effect covers most of the screen and is multiple layers, even the simplest shader can make the iphone dumbfounded.
We recommend baking your particle effect into a texture sequence diagram.
You can then use 1-2 of particles at run time to display them through animated textures. This approach can achieve very good results at minimal cost.

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.



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.

====================== Split Line ==================
Number of role material
2-3 x
Number of bones
Less than 30
Number of patches
300-1500
The general role should have no IK nodes.
This is because most of the character's actions are pre-set and do not require an IK operation for real-time calculations (except for rogdoll), so do not import IK nodes together when the model is imported.

2, static entities do not attach animation Component
Attaching a animation part to a static entity has no effect on the result, but adds some CPU overhead to invoke the component, so remove the component as much as possible.
Grid Top points
Less than 500
UV value range try not to exceed (0, 1) intervals
Try to ensure that the UV values do not cross out, which is useful for future texture flattening optimizations.

3. The resolution size of topographic topography
The length and width are as small as 257. This is because the terrain is too large, will cause a lot of vertex data, to your memory bandwidth has a certain impact, in the current iOS device, memory bandwidth is very limited, need to try to save. At the same time, if you use Unity's own terrain, you must also use occlusion culling, because unity's brush terrain tool, although convenient, but it is framekiller, after brushing, you will find that drawcall increased a lot.
Number of mixed textures
Do not exceed 4. The blending of the terrain is time consuming and should be avoided as much as possible. The textures that can be merged are merged as much as possible.

4. Texture Texture Format
PNG or TGA is recommended. Don't turn into the PVRTC format supported by iOS hardware, because unity will automatically turn it on when it's released.
Texture size
The length of the width is less than 1024. At the same time should be as small as possible, good enough to ensure that the texture of the memory bandwidth to minimize the impact.
Support Mipmap
It is recommended to generate mipmap. While this practice increases the size of some applications, when the game is running, the system uses MIPMAP to render as needed, reducing memory bandwidth.
Check alpha value
If the alpha channel of the texture is 1, the RGB 24-bit texture is used instead of the RGBA 32-bit texture. (automatic detection is said to be internal to unity)

5. The number of light source "Important"
Recommended 1, generally for directional light. The number of "Important" should be as small as possible. The more the number, the more drawcall.
Pixel Light Number
1-2 of them.

6. The maximum number of particles on the particle effect screen

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.