Optimizing graphics performance (IOS)

Source: Internet
Author: User
Alpha-Testing

The overhead of using alpha-testing on iOS is very high. Try to replace alpha-test shader with alpha-blend.

Vertex Performance

Control the rendering of up to 40 thousand vertices per frame (over 10 thousand faces) on the iPhone 3gs and new hardware ).

Lighting performance

In pixel-level dynamic illumination computing, computing overhead is greatly increased because each affected pixel needs to be calculated, and multiple passes are rendered for the object. Try to avoid multiple pixel light effects on a single object and try to use the direction light. Pixel light refers to the light that sets the render mode to important.

Vertex-level dynamic illumination calculation will affect the overhead of vertex transformation, and avoid multiple lights affecting a single object at the same time. If possible, use a pre-baked illumination chart.

Optimize Model
Geometry

Two criteria for Model Optimization:
Remove unnecessary faces and delete those that will never be displayed.
Minimize the seams and hard edge of UV ing)

Note: The number of vertices actually rendered by the graphic hardware is different from the number of vertices seen in the 3D modeling software. The number of vertices displayed in the modeling software is the actual number of vertices that constitute the model, when rendering in the engine, some vertices need to be divided into multiple, for example, those vertices with multiple headers, or vertices with multiple UV coordinates and those with multiple color values must be split into multiple. Therefore, the number of vertices seen in unity is generally different from that seen in modeling software.

Texture Compression

Try to use the built-in pvrt compression format in IOS. It not only reduces the size of the texture file, but also speeds up game loading and requires less inner points, and significantly improves rendering performance.

If the image has an alpha channel, it may appear that there are some problems after the pvrt compression format is used. In this case, you can use pvrtextool to generate. PVR files with pvrt Compression Parameters. After importing these compressed images, the Unity engine can better restore the original images.

If the pvrt compression format cannot meet the requirements of image quality, for example, for UI textures, the 16-bit image format can be used, this also saves half of the total 32-bit rgba image space.

Tips for writing well known Ming shaders

After the iPhone 3gs, the GPU has started to fully support vertex shader and pixel shader, but it cannot expect the same complex shader as the Desktop System on the iOS platform, after all, the hardware performance of IOS is still limited.

Complex armetic operations

Arithmetic computation similar to POW, exp, log, cos, sin, Tan may cause a lot of GPU overhead. Generally, this call should not exceed one time in each fragment. A better way is to retrieve data by searching for texture.

Do not use the normalize, Dot, inverse, and SQRT functions written by yourself. Use built-in drivers to generate more optimized implementations for these functions.

Minimize the use of discard operations, which slows down fragments.

Floating point operations

When using floating point numbers, you must specify the size and use the smallest format.
If you use glsl es to write a shader, the data format is:
1. highp's complete 32-bit floating point format is suitable for vertex transformation computation and the speed is relatively slow.
2. mediump 16-bit floating point format, applicable to UV coordinates, about twice faster than highp
3. lowp 10-Bit fixed-point format, applicable to colors and lighting computing, which is about four times faster than highp

The shader of CG is similar to glsl es. The three formats are float, half, and fixed.

Bake lighting into lightmaps

Try to pre-render the static light as much as possible. Unity provides the built-in lightmapper tool.
Using a lightmap only consumes a little more time to generate, but it brings more benefits:
1. The rendering speed can be increased by 2 to 3 times in the case of two pixel-level illumination
2. smoother lighting performance

Share Materials

If multiple objects are rendered to the same camera using the same material, unity IOs can use a series of optimization methods:
1. Avoid switching a large number of rendering statuses
2. avoid pausing vertex and pixel processing due to different parameters.
3. Multiple small removable objects are rendered in the same batch to reduce the number of draw calls.
Allows multiple removable objects with the "static" attribute to be rendered in the same batch regardless of the size to reduce the number of draw calls.

Each step above can greatly reduce the CPU overhead, so try to merge multiple small maps into a large image, so that as many objects as possible can use the same large texture.

Simple checklist to make your game faster

Several optimization checkpoints:
1. control rendering of up to 40 thousand vertices per frame on iPhone 3gs and new hardware
2. If you use the built-in shader, try to select under the mobile category, where mobile/vertexader is currently the fastest
3. Minimize the number of visible materials on each screen and share the materials as much as possible.
4. Mark all objects that are not moved with the "static" attribute
5. Use pvrtc format or 16-bit texture as much as possible.
6. Try to use combiners or pixel shader to mix multiple textures, and avoid using multiple pass methods.
7. If you write your own shader, try to use a small floating point number format.
8. Avoid time-consuming arithmetic calculations as much as possible
9. Unless necessary, ensure that only one pixel light will affect the object.
10. Unless necessary, do not use dynamic light. You can use the pre-baking method instead.
11. Use as few textures as possible
12. Use alpha-testing instead of alpha-blending.
13. Do not use fog unless necessary
14. Try to use blocks in the scene to reduce the number of objects to be rendered
15. Use the sky box to remove objects from the distance

 

Address: http://unity3d.com/support/documentation/Manual/Optimizing%20Graphics%20Performance.html

Original article, reprinted Please note:Reprinted from All-iPad.net

Link:Optimizing
Graphics performance (IOS)

Related Article

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.