• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Immortalis94 · May 29, 2018 at 11:03 AM · mobileshader programmingperformance optimization

Thermal throttling - Bad shaders, too many vertices/triangles or too many drawcalls?

I am using custom Surface shader for all scene objects and custom Gradient UI shader for some parts of the UI and Beautify mobile post processing with only bloom enabled. My v-sync is set to Every V Blank, without it game cant go above 30FPS. Using Unity 2017.4.1f1

Scene stats:
  - 1 Directional light 1 point light no shadows
  - Drawcalls: 49
  - Saved by batching: 35
  - Verts: 45k
  - Tris: 49k
  - SetPass calls: 49
  - Shadow casters: 0
  - Animations: 0

Device i am testing on is Samsung Galaxy S8+
Game tests:
  - Full resolution 60FPS for about 1 min and then it starts going down and lagging
  - 1080p res 60FPS for about 2-4mins then it has the same behaviour as FullRes
  - 720p no thermal throttling but quality sucks even with MSAA x8

Above tests are done with development mode turned off as for 2 with thermal throttling i enabled it and checked with profiler and Camera.render takes like 8-9ms and Gfx.WaitForPresent takes most of the time when frames start dropping. Here are the shaders:
Surface shader

 Shader "Custom/Mobile/DoubleSurface Bump" {
     Properties {
         _CombTex ("SurfaceMask(R) Occlusion(G) Map", 2D) = "white" {}
         _BumpMap ("Normal Map", 2D) = "bump" {}
 
         _AlbedoColor1 ("Color 1", Color) = (1, 1, 1, 1)
         _Metallic1 ("Metallic", Range(0,1)) = 0.0
         _Glossiness1 ("Smoothness", Range(0,1)) = 0.5
         _AlbedoColor2 ("Color 2", Color) = (1, 1, 1, 1)
         _Metallic2 ("Metallic", Range(0,1)) = 0.0
         _Glossiness2 ("Smoothness", Range(0,1)) = 0.5
         _OcclusionStrength ("Occlusion Strength", Range(0, 1)) = 1
         _OcclusionMultiplier ("Occlusion Multiplier", Range(0, 1)) = 1
     }
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
 
         CGPROGRAM
         // Physically based Standard lighting model, and enable shadows on all light types
         #pragma surface surf Standard noshadow noforwardadd noambient interpolateview
         //#pragma multi_compile SEPARATE_ALPHA
 
         // Use shader model 3.0 target, to get nicer looking lighting
         #pragma target 3.0
 
         sampler2D _CombTex;
         sampler2D _BumpMap;
 
         struct Input {
             float2 uv_CombTex;
             float2 uv_BumpMap;
         };
 
         fixed4 _AlbedoColor1;
         half _Metallic1;
         half _Glossiness1;
         fixed4 _AlbedoColor2;
         half _Metallic2;
         half _Glossiness2;
         half _OcclusionStrength;
         half _OcclusionMultiplier;
 
         // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
         // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
         // #pragma instancing_options assumeuniformscaling
         UNITY_INSTANCING_BUFFER_START(Props)
             // put more per-instance properties here
         UNITY_INSTANCING_BUFFER_END(Props)
 
         void surf (Input IN, inout SurfaceOutputStandard o) {
             // Evaluating maps
             fixed4 comb = tex2D (_CombTex, IN.uv_CombTex);
             fixed3 normals = UnpackNormal(tex2D (_BumpMap, IN.uv_BumpMap));
 
             // Occlusion calculation
             half occlusion = pow (comb.g, _OcclusionStrength) * _OcclusionMultiplier;
             half difference = 1 - comb.r;
             
             o.Albedo = _AlbedoColor1 * comb.r + _AlbedoColor2 * difference;
             o.Metallic = _Metallic1 * comb.r + _Metallic2 * difference;
             o.Smoothness = _Glossiness1 * comb.r + _Glossiness2 * difference;
             o.Normal = normals;
             o.Occlusion = occlusion;
             o.Alpha = comb.a;
         }
         ENDCG
     }
     FallBack "Diffuse"
 }
 


UI Shader

 // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
 
 Shader "UI/DiagonalGradient"
 {
     Properties
     {
         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
         _Color ("Tint1", Color) = (1,1,1,1)
         _Color2 ("Tint2", Color) = (0,0,0,1)
 
         _StencilComp ("Stencil Comparison", Float) = 8
         _Stencil ("Stencil ID", Float) = 0
         _StencilOp ("Stencil Operation", Float) = 0
         _StencilWriteMask ("Stencil Write Mask", Float) = 255
         _StencilReadMask ("Stencil Read Mask", Float) = 255
 
         _ColorMask ("Color Mask", Float) = 15
 
         [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
     }
 
     SubShader
     {
         Tags
         {
             "Queue"="Transparent"
             "IgnoreProjector"="True"
             "RenderType"="Transparent"
             "PreviewType"="Plane"
             "CanUseSpriteAtlas"="True"
         }
 
         Stencil
         {
             Ref [_Stencil]
             Comp [_StencilComp]
             Pass [_StencilOp]
             ReadMask [_StencilReadMask]
             WriteMask [_StencilWriteMask]
         }
 
         Cull Off
         Lighting Off
         ZWrite Off
         ZTest [unity_GUIZTestMode]
         Blend SrcAlpha OneMinusSrcAlpha
         ColorMask [_ColorMask]
 
         Pass
         {
             Name "Default"
         CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma target 2.0
 
             #include "UnityCG.cginc"
             #include "UnityUI.cginc"
 
             #pragma multi_compile __ UNITY_UI_ALPHACLIP
 
             struct appdata_t
             {
                 float4 vertex   : POSITION;
                 float4 color    : COLOR;
                 float2 texcoord : TEXCOORD0;
                 UNITY_VERTEX_INPUT_INSTANCE_ID
             };
 
             struct v2f
             {
                 float4 vertex   : SV_POSITION;
                 fixed4 color    : COLOR;
                 float2 texcoord  : TEXCOORD0;
                 float4 worldPosition : TEXCOORD1;
                 UNITY_VERTEX_OUTPUT_STEREO
             };
 
             fixed4 _Color;
             fixed4 _Color2;
             fixed4 _TextureSampleAdd;
             float4 _ClipRect;
 
             v2f vert(appdata_t v)
             {
                 v2f OUT;
                 UNITY_SETUP_INSTANCE_ID(v);
                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
                 OUT.worldPosition = v.vertex;
                 OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
                 OUT.texcoord = v.texcoord;
                 OUT.color = v.color * _Color;
                 return OUT;
             }
 
             sampler2D _MainTex;
 
             fixed4 frag(v2f IN) : SV_Target
             {
                 half step = abs(IN.texcoord.x - 1 + IN.texcoord.y);
                 half smoothStep = smoothstep(0, 1, step);
                 smoothStep *= smoothStep;
                 fixed4 gradient = lerp(_Color, _Color2, smoothStep * 2);
                 fixed4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * gradient;
 
                 #ifdef UNITY_UI_CLIP_RECT
                 color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
                 #endif
 
                 #ifdef UNITY_UI_ALPHACLIP
                 clip (color.a - 0.001);
                 #endif
 
                 return color;
             }
         ENDCG
         }
     }
 }
 

I can't find where is the problem. Are these shaders too heavy for mobile? Are there too many triangles? Is there a problem in post-processing?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

178 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Performance-increase/loading-time problem [object pool] 0 Answers

extend Mobile-Bumped and Mobile-BumpedSpec.shader with color 1 Answer

Mobile Performance Issues 0 Answers

No physics object gravity-driven movement? 0 Answers

My game has only ui elements and its Heating up my phone 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges