Android game optimizer based on the Unity3d engine

Source: Internet
Author: User

Reprint Source: http://www.manew.com/thread-47240-1-1.html

Recent projects into the closing phase, before the project has done a lot of optimization, mesh merge, reduce drawcall and model bones and physical computing, combined material ball, optimization code and so on, on iOS fortunately, but on, tried several mobile phones, from the low to high end, found that performance is still poor, So it took a few days to explore and finally put the game performance. Record it and leave it for future reference.

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

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

3. Reduce FPS, the VSync Count parameter in projectsetting-> quality 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 set FPS, and then adjust the fixed timestep This parameter, this parameter in Projectsetting->time, the purpose is to reduce the number of physical calculations, 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.

VSync Count Vertical Synchronization

When creating a new scene in 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, select Edit->project settings->quality in the right panel to find VSync Count, and choose 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 the operation of the monitor, all the images on the display is a front-line scan up, whether interlaced or progressive scan, the display has two synchronization parameters-horizontal synchronization and vertical synchronization.

What does horizontal synchronization mean? What does vertical sync mean?

Vertical and horizontal is the CRT in two basic synchronization signal, horizontal synchronization signal determines the CRT to draw a cross-screen time, vertical synchronization signal determines the CRT from the top of the screen to draw to the bottom, and then return to the original location of the time, and precisely vertical synchronization represents the level of the CRT display refresh rate.

Why does turning off the vertical sync signal affect the FPS value in the game?

The truth is not complicated, first of all, we usually run the operating system General screen refresh rate is how much? Probably usually in the 85 up and down, then the video card will be 85 per frequency time to send a vertical synchronization signal, signal and signal time interval is the last two times the screen update interval.

If we choose to wait for the vertical synchronization signal (which is what we normally call vertical synchronization open), then in the game may be a strong graphics card quickly finished drawing a screen of the image, but no vertical synchronization signal arrives, the video card can not draw the next screen, only 85 units of the signal arrived, only to draw. This way FPS is naturally subject to operating system refresh rate running value.

And if we choose not to wait for the vertical synchronization signal (that is what we usually say to turn off vertical synchronization), then in the game to complete a screen, graphics card and monitor without waiting for vertical synchronization signal can 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.

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, for some older devices with MBX GPUs (for example, the original 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 transform. 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 a character 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 only has one Skinned Mesh Renderer will not start. 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 add components to static objects, although adding no effect on the results, but will increase 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 based on different layers, so we can achieve layering of objects, large object layer set the visible distance, and 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 clipping plane, occlusion culling, occlusion culling, Unity embedded umbra, a very good OC library. But occlusion culling is not universal, sometimes OC is slower than not, it is recommended to determine whether their scene is suitable to use OC to optimize 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 required texture size, increases the memory bandwidth burden. This is why there will be "drawcall down, rendering speed has slowed down" reason.

Android game optimizer based on Unity3d engine (RPM)

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.