Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Customized Unlit shader becomes dirty on iOS devices

Discussion in 'Shaders' started by JackTruong, Jul 2, 2021.

  1. JackTruong

    JackTruong

    Joined:
    May 8, 2021
    Posts:
    19
    Hi,
    I'm using a customized unlit shader for my characters. Everything works fine on Android devices but for some reasons, characters look so weird and dirty on iOS. On the other hand, even Standard shader fails either (as u can see in the images below).
    Solutions I've tried:
    + Changing texture compressing modes: ASTC, PVRTC, ETC, None.
    + Disabling Directional Light (cause my shader is affected a little bit by environment lighting).
    I really appreciate if someone can give me some advices to resolve this problem. Thanks in advance
    android.png ios.png
    Here is the shader file
    Code (CSharp):
    1. // Made with Amplify Shader Editor
    2. // Available at the Unity Asset Store - http://u3d.as/y3X
    3. Shader "ASESampleShaders/Simple/SimpleUnlit"
    4. {
    5.     Properties
    6.     {
    7.         _MainTex("Main Texture", 2D) = "white" {}
    8.         _TintColor("_TintColor", Color) = (1,1,1,1)
    9.         _FillAmount("_FillAmount", Range( 0 , 1)) = 0
    10.         [HideInInspector] _texcoord( "", 2D ) = "white" {}
    11.         [HideInInspector] __dirty( "", Int ) = 1
    12.     }
    13.  
    14.     SubShader
    15.     {
    16.         Tags{ "RenderType" = "TransparentCutout"  "Queue" = "AlphaTest+0" "IsEmissive" = "true"  }
    17.         Cull Back
    18.         CGPROGRAM
    19.         #pragma target 2.0
    20.         #pragma surface surf Standard keepalpha addshadow fullforwardshadows
    21.         struct Input
    22.         {
    23.             float2 uv_texcoord;
    24.         };
    25.  
    26.         uniform sampler2D _MainTex;
    27.         uniform float4 _MainTex_ST;
    28.         uniform float4 _TintColor;
    29.         uniform float _FillAmount;
    30.  
    31.         void surf( Input i , inout SurfaceOutputStandard o )
    32.         {
    33.             float2 uv_MainTex = i.uv_texcoord * _MainTex_ST.xy + _MainTex_ST.zw;
    34.             float4 lerpResult219 = lerp( tex2D( _MainTex, uv_MainTex ) , _TintColor , _FillAmount);
    35.             o.Emission = lerpResult219.rgb;
    36.             o.Alpha = 1;
    37.         }
    38.  
    39.         ENDCG
    40.     }
    41.     Fallback "Diffuse"
    42.     CustomEditor "ASEMaterialInspector"
    43. }
    44. /*ASEBEGIN
    45. Version=18900
    46. 2048;60;1920;782;-1041.773;525.7384;1;True;True
    47. Node;AmplifyShaderEditor.SamplerNode;210;1508.853,-460.1006;Inherit;True;Property;_MainTex;Texture Sample 0;1;0;Create;True;0;0;0;False;0;False;-1;c0b4cb492d192e44788311ec4742ca3e;c0b4cb492d192e44788311ec4742ca3e;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;8;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;6;FLOAT;0;False;7;SAMPLERSTATE;;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
    48. Node;AmplifyShaderEditor.RangedFloatNode;218;1509.656,44.50873;Inherit;False;Property;_FillAmount;_FillAmount;3;0;Create;True;0;0;0;False;0;False;0;0;0;1;0;1;FLOAT;0
    49. Node;AmplifyShaderEditor.ColorNode;216;1526.828,-210.8117;Inherit;False;Property;_TintColor;_TintColor;2;0;Create;True;0;0;0;False;0;False;1,1,1,1;1,1,1,1;True;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
    50. Node;AmplifyShaderEditor.LerpOp;219;1952.656,-290.4913;Inherit;True;3;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0;False;1;COLOR;0
    51. Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;2329.304,-337.1997;Float;False;True;-1;0;ASEMaterialInspector;0;0;Standard;ASESampleShaders/Simple/SimpleNoise;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;3;False;-1;False;0;False;-1;0;False;-1;False;0;Masked;0.28;True;True;0;False;TransparentCutout;;AlphaTest;All;14;all;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;1;4;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;1;False;-1;1;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;0;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;False;0.1;False;-1;0;False;-1;False;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
    52. WireConnection;219;0;210;0
    53. WireConnection;219;1;216;0
    54. WireConnection;219;2;218;0
    55. WireConnection;0;2;219;0
    56. ASEEND*/
    57. //CHKSM=5546FEE60A5E14A2EC2089EF00B06C55237DEAB6
     

    Attached Files:

    Last edited: Jul 3, 2021
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    The short version is ... that this is not an unlit shader.

    Your ASE shader's output settings are set to Shader Type > Surface Shader, Light Model > Standard. And just because you don't set an albedo doesn't mean it doesn't receive any light or have any reflections. On different platforms the Standard lighting model uses different code, so it ends up shinier on mobile than on desktop.

    You want to use Shader Type > Unlit.
     
    JackTruong likes this.
  3. JackTruong

    JackTruong

    Joined:
    May 8, 2021
    Posts:
    19
    Thank you for your help, I really appreciate that.
    Cause I made this using Amplify Shader Editor, I tried to contact their support team before posting here and they said the same. Tbh, it works. But the skin surface is darken so I think I need to adjust my textures to make it brighter. If u think I should use any other solution, please let me know.
     
  4. Yiming075

    Yiming075

    Joined:
    Mar 24, 2017
    Posts:
    32
    What is the cause of the dirty result?
     
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,627
    If you have a specific question, start a new thread. In this case the issue is that even though OP thought he was making an unlit shader, he was actually making a LIT shader, so the shader had all kinds of reflections and lighting etc, which look a bit different between desktop and mobile.