Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Device overheat. Shader problem?

Discussion in 'Android' started by zreek17, Jun 16, 2015.

  1. zreek17

    zreek17

    Joined:
    Jun 2, 2013
    Posts:
    21
    Hello everyone!
    I am developing my endless runner game, and my game overheats a device (Sams. Galaxy S3) very fast.
    Can't make a screen of stats, here is main info:
    Draw calls: 14-20,
    Verts: 15k-25k.
    All textures are max. 1024x1024 size.
    I need a bending effect of environment, so shaders look as follows:
    Bending_Diffuse
    Code (csharp):
    1. Shader "MyShaders/Diffuse_Color" {
    2. Properties {
    3.   _Color ("Main Color", Color) = (1,1,1,1)
    4.   _MainTex ("Texture", 2D) = "white" {}
    5.   // _QOffset ("Offset", Vector) = (0,0,0,0)
    6.   _Dist ("Distance", Float) = 200.0
    7.  
    8.   }
    9.   SubShader {
    10. Tags { "RenderType"="Opaque" }
    11. LOD 10
    12.   CGPROGRAM
    13.   #pragma surface surf Lambert vertex:vert
    14.  
    15.   struct Input
    16.   {
    17.   float2 uv_MainTex;
    18.   float4 pos : SV_POSITION;
    19.   };
    20.  
    21.   sampler2D _MainTex;
    22.   fixed4 _Color;
    23.   float4 _QOffset;
    24.   fixed _Dist;
    25.  
    26.   void vert (inout appdata_full v)
    27.   {
    28. float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
    29.   float zOff = vPos.z/_Dist;
    30.   vPos += _QOffset*zOff*zOff;
    31.   v.vertex = mul(transpose(UNITY_MATRIX_IT_MV), vPos);
    32.   }
    33.  
    34.  
    35.   void surf (Input IN, inout SurfaceOutput o)
    36.   {
    37. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    38. o.Albedo = c.rgb;
    39. o.Alpha = c.a;
    40. }
    41.   ENDCG
    42.   }
    43.   Fallback "Diffuse"
    44.   }
    Bending_DiffuseDetail:
    Code (csharp):
    1. Shader "MyShaders/Diffuse_Detail_Color" {
    2. Properties {
    3.   _Color ("Main Color", Color) = (1,1,1,1)
    4.   _MainTex ("Texture", 2D) = "white" {}
    5.   //_QOffset ("Offset", Vector) = (0,0,0,0)
    6.   _Dist ("Distance", Float) = 200.0
    7.   _Detail ("Detail (RGB)", 2D) = "gray" {}
    8.   }
    9.   SubShader {
    10. Tags { "RenderType"="Opaque" }
    11. LOD 10
    12.   CGPROGRAM
    13.   #pragma surface surf Lambert vertex:vert
    14.  
    15.   struct Input
    16.   {
    17.   float2 uv_MainTex;
    18.   float2 uv_Detail;
    19.   float4 pos : SV_POSITION;
    20.   };
    21.  
    22.   sampler2D _MainTex;
    23.   sampler2D _Detail;
    24.   fixed4 _Color;
    25.   float4 _QOffset;
    26.   fixed _Dist;
    27.  
    28.   void vert (inout appdata_full v)
    29.   {
    30. float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
    31.   float zOff = vPos.z/_Dist;
    32.   vPos += _QOffset*zOff*zOff;
    33.   v.vertex = mul(transpose(UNITY_MATRIX_IT_MV), vPos);
    34.   }
    35.  
    36.  
    37.   void surf (Input IN, inout SurfaceOutput o)
    38.   {
    39. fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    40. c.rgb *= tex2D(_Detail,IN.uv_Detail).rgb*2;
    41. o.Albedo = c.rgb;
    42. o.Alpha = c.a;
    43. }
    44.   ENDCG
    45.   }
    46.   Fallback "Diffuse"
    47.   }
    What do U think, do these shaders look good enough for mobile, or bending effect makes it very complex to display?
     
  2. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    How do you know the Shader is causing these overheat issues?
     
  3. zreek17

    zreek17

    Joined:
    Jun 2, 2013
    Posts:
    21
    I am not sure, that shader can be the main reason.
    Also I tries to analyze other aspects, like scripts and gameobjects in my game.
    Scripts are quite simple and amount of draw calls and verts is very good for mobile.
    The game on device runs smooth, but overheats it like from the 1st second, so I decided, that shader can be a reason for this.
     
  4. mbowen89

    mbowen89

    Joined:
    Jan 21, 2013
    Posts:
    639
  5. zreek17

    zreek17

    Joined:
    Jun 2, 2013
    Posts:
    21
    wow thanks, gonna check it
     
  6. Marceta

    Marceta

    Joined:
    Aug 5, 2013
    Posts:
    177
    It's probably because you are using new shaders or some of graphics features which came with Unity5. I had same problem, so i changed back shaders to mobile shaders and turned off GI and all that new fancy graphic features.
     
  7. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Actually the frame rate fix does not stop overheating but does help:.With the GUI updates in next Unity update, reduced drawcalls might help