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

Mobile overheat. Shader problem?

Discussion in 'Shaders' started by zreek17, Jun 15, 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.
    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. zreek17

    zreek17

    Joined:
    Jun 2, 2013
    Posts:
    21
    still actual, pleease
     
  3. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,960
    You will be the one to decide that. You should use adb and internal profilers to check for your CPU and GPU time. This will give you the greatest insight into the strain of your code on your device.