Unity shader--Mobile-Shader optimization (Optimize Shader)

Source: Internet
Author: User

This reference book "Unity Shaders and Effects CookBook".


First of all, the simple Shader Cheap Shader, lightweight Shader is mainly memory consumption, map usage, and data usage to optimize.




The following is a detailed talk about those optimizations 1. Change variable type (reduce memory)
First of all, a few variable types: float:32 bit floating point data, corresponding to the value of FLOAT2,FLOAT3,FLOAT4, the following data represents an array, such as FLOAT2 (1.0f,1.0f) half:16 bit floating point data, using and storing UV values, color values, is much faster than using the float value, the corresponding value has HALF2,HALF3,HALF4 fixed:12 bit fixed-point number, used for the calculation of light color, the corresponding value is fixed2,fixed3,fixed4.
Here are some examples of two types of changes:
One: Change the UV value type, changed from float to half
Before the change:

After the change:


Second: Change the value type in the light color calculation
Light calculation:





Color calculation:



2. Turn off render additional channels (reduce lights Shader process) or specify rendering directly

To turn off rendering additional channels:




Specify rendering:


Similar to the following:

3. Sharing Uvs (sharing UVS)



Remove the input from the normal map and use Unpcknormal to share the Uvs.

4. Control based on Unity's own performance Analyzer


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.