Search Unity

Shaders breaking on specific android devices [Urgent, over live 30k players have the issue]

Discussion in 'Shaders' started by Stef_Morojna, Jun 6, 2020.

  1. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Yesterday I released a new update to my playerbase, test went well, until I released to a 100% of players
    This is the bug in question: https://i.imgur.com/hb00nx2.png
    The bug appears to happen to around 2-3% of players, which adds up to around 30k players.

    The issue seems to be device specific, and seems to mostly happen to older phones.

    Shaders with issues:
    Part shader:
    Code (CSharp):
    1. Shader "Sprites/Part"
    2. {
    3.     Properties
    4.     {
    5.         _TextureAtlas("Texture Atlas", 2D) = "white" {}
    6.         _Intensity("Shade Intensity", float) = 0
    7.     }
    8.  
    9.     SubShader
    10.     {
    11.         Tags
    12.         {      
    13.             "Queue" = "Transparent"
    14.             "IgnoreProjector" = "True"
    15.             "RenderType" = "Transparent"  
    16.             "PreviewType" = "Plane"
    17.         }
    18.  
    19.         Cull Off
    20.         Lighting Off
    21.         Blend One OneMinusSrcAlpha
    22.    
    23.         Pass {
    24.         CGPROGRAM
    25. #pragma vertex vert
    26. #pragma fragment frag
    27. #pragma target 2.0
    28. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
    29. #include "UnityCG.cginc"
    30.  
    31.     struct appdata_t
    32.     {
    33.         float4 vertex : POSITION;
    34.         fixed4 color : COLOR;
    35.         float3 UVQ_0 : TEXCOORD0;
    36.         float3 UVQ_1 : TEXCOORD1;
    37.         float3 UVQ_2 : TEXCOORD2;
    38.         float3 UVQ_3 : TEXCOORD3;
    39.  
    40.         UNITY_VERTEX_INPUT_INSTANCE_ID
    41.     };
    42.  
    43.     struct v2f
    44.     {
    45.         float4 vertex : SV_POSITION;
    46.         fixed4 color : COLOR;
    47.         float3 UVQ_0 : TEXCOORD0;
    48.         float3 UVQ_1 : TEXCOORD1;
    49.         float3 UVQ_2 : TEXCOORD2;
    50.         float3 UVQ_3 : TEXCOORD3;
    51.  
    52.         UNITY_VERTEX_OUTPUT_STEREO
    53.     };
    54.  
    55.     v2f vert(appdata_t IN)
    56.     {
    57.         v2f OUT;
    58.  
    59.         UNITY_SETUP_INSTANCE_ID(IN);
    60.         UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
    61.  
    62.         OUT.vertex = UnityObjectToClipPos(IN.vertex);
    63.  
    64.         OUT.UVQ_0 = IN.UVQ_0;
    65.         OUT.UVQ_1 = IN.UVQ_1;
    66.         OUT.UVQ_2 = IN.UVQ_2;
    67.         OUT.UVQ_3 = IN.UVQ_3;
    68.         OUT.color = IN.color;
    69.  
    70.         return OUT;
    71.     }
    72.  
    73.     sampler2D _TextureAtlas;
    74.     float _Intensity;
    75.  
    76.     fixed4 frag(v2f IN, out float depth : SV_Depth) : SV_Target
    77.     {
    78.         // Color texture // Vertice color
    79.         fixed4 c = tex2D(_TextureAtlas, IN.UVQ_0.xy / IN.UVQ_0.z) * IN.color;
    80.  
    81.         // Shape texture // Shadow texture
    82.         float albedo = tex2D(_TextureAtlas, IN.UVQ_1.xy / IN.UVQ_1.z).r * 1.85 * (1 - (1 - tex2D(_TextureAtlas, IN.UVQ_2.xy / IN.UVQ_2.z).r) * _Intensity);
    83.  
    84.         // Alpha / Albedo
    85.         c.rgb *= albedo * c.a;
    86.  
    87.         // Depth
    88.  
    89. #if defined(UNITY_REVERSED_Z)
    90.         depth = IN.UVQ_3.x;
    91. #else
    92.         depth = 1.0f - IN.UVQ_3.x;
    93. #endif
    94.  
    95.         return c;
    96.     }
    97.         ENDCG
    98.     }
    99.     }
    100. }
    Terrain shader:
    Code (CSharp):
    1. Shader "SFS/Terrain"
    2. {
    3.     Properties
    4.     {
    5.         _PlanetTexture ("Planet Texture", 2D) = "white" {}
    6.         _PlanetTextureCutout ("Planet Texture Cutout", Float) = 1
    7.  
    8.         _TextureA ("Texture A", 2D) = "white" {}
    9.         _TextureB ("Texture B", 2D) = "white" {}
    10.         _TextureTerrain ("Texture Terrain", 2D) = "white" {}
    11.  
    12.         _RepeatA ("Repeat A", Vector) = (1,1,1,1)
    13.         _RepeatB ("Repeat B", Vector) = (1,1,1,1)
    14.         _RepeatTerrain ("Repeat Terrain", Vector) = (1,1,1,1)
    15.  
    16.         _SurfaceSize ("Texture Transition", Float) = 1
    17.  
    18.         _Min ("Min fade", Float) = 0  
    19.         _Max ("Max fade", Float) = 1
    20.  
    21.         _ShadowSize ("Transition shade", Float) = 1
    22.         _ShadowIntensity ("Shade intensity", Float) = 1  
    23.    
    24.         _Fog ("Atmosphere Color", Color) = (1,1,1,1)
    25.  
    26.         _Depth("Depth",  float) = 0
    27.     }
    28.  
    29.     SubShader {
    30.  
    31.         Tags {      
    32.             "Queue" = "Transparent"
    33.             "IgnoreProjector" = "True"
    34.             "RenderType" = "Opaque"
    35.             "PreviewType" = "Plane"
    36.         }
    37.  
    38.         Cull Off
    39.         Lighting Off
    40.         ZWrite Off
    41.         Blend Off
    42.  
    43.         Pass {
    44.         CGPROGRAM
    45. #pragma vertex vert
    46. #pragma fragment frag
    47. #pragma target 2.0
    48. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
    49.  
    50. #include "UnityCG.cginc"
    51.  
    52.     // Data passed into the vert function
    53.     struct appdata_t
    54.     {
    55.         float4 vertex : POSITION;
    56.         float2 uv : TEXCOORD0;
    57.         float2 uv2 : TEXCOORD1;
    58.         float2 uv3 : TEXCOORD2;
    59.     };
    60.  
    61.     // Data passed into the frag function
    62.     struct v2f
    63.     {
    64.         float4 vertex : SV_POSITION;
    65.         float2 uv : TEXCOORD0;
    66.         float2 uv2 : TEXCOORD1;
    67.         float2 uv3 : TEXCOORD2;
    68.     };
    69.  
    70.     float _ShadowIntensity;
    71.  
    72.     v2f vert(appdata_t IN){
    73.  
    74.         v2f OUT;
    75.        
    76.         OUT.vertex = UnityObjectToClipPos( IN.vertex);
    77.  
    78.         OUT.uv = IN.uv;
    79.         OUT.uv2 = IN.uv2;
    80.  
    81.         OUT.uv3 = float2( IN.uv3.x * _ShadowIntensity, IN.uv3.y);
    82.  
    83.         return OUT;
    84.     }
    85.  
    86.     sampler2D _PlanetTexture;
    87.     float _PlanetTextureCutout;
    88.  
    89.     sampler2D _TextureA;
    90.     float4 _RepeatA;
    91.     sampler2D _TextureB;
    92.     float4 _RepeatB;
    93.     sampler2D _TextureTerrain;
    94.     float4 _RepeatTerrain;
    95.  
    96.     float _SurfaceSize;
    97.  
    98.     float _Max;
    99.     float _Min;
    100.    
    101.     float _ShadowSize;
    102.  
    103.     float4 _Fog;
    104.  
    105.     float _Depth;
    106.  
    107.     fixed4 frag(v2f IN, out float depth : SV_Depth) : SV_TARGET
    108.     {
    109.         depth = _Depth;
    110.  
    111.         IN.uv = float2(IN.uv.x / (1 - IN.uv.y), IN.uv.y);
    112.  
    113.         float lerpAmount = clamp( IN.uv.y * _SurfaceSize, _Min, _Max);
    114.  
    115.         float grayscale =
    116.         (
    117.         (tex2D( _TextureA, IN.uv * _RepeatA.xy).r * (1 - IN.uv3.y) + tex2D( _TextureB, IN.uv * _RepeatB.xy).r * (IN.uv3.y) ) * (1 - lerpAmount) // Surface texture
    118.         +
    119.         tex2D( _TextureTerrain, IN.uv * _RepeatTerrain.xy ).r * (0.95 * lerpAmount) // Terrain texture
    120.         )
    121.         *
    122.         2
    123.         *
    124.         (1 + IN.uv3.x * (1 - min( 1, IN.uv.y * _ShadowSize)) ); // Shade
    125.  
    126.         float4 f4 = (tex2D( _PlanetTexture, IN.uv2 * _PlanetTextureCutout + 0.5) * grayscale) * (1 - _Fog.a) + (_Fog * _Fog.a);
    127.  
    128.         f4.a = 1;
    129.  
    130.         return f4;
    131.     }
    132.         ENDCG
    133.     }
    134.     }
    135. }
    Sprite shader:
    Code (CSharp):
    1. Shader "SFS/Sprite"
    2. {
    3.     Properties
    4.     {
    5.         [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
    6.         _Color("Tint", Color) = (1,1,1,1)
    7.         _Depth("Depth",  float) = 0
    8.         [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
    9.         [HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
    10.         [HideInInspector] _Flip("Flip", Vector) = (1,1,1,1)
    11.         [PerRendererData] _AlphaTex("External Alpha", 2D) = "white" {}
    12.         [PerRendererData] _EnableExternalAlpha("Enable External Alpha", Float) = 0
    13.     }
    14.  
    15.     SubShader
    16.     {
    17.         Tags
    18.         {
    19.             "Queue" = "Transparent"
    20.             "IgnoreProjector" = "True"
    21.             "RenderType" = "Transparent"
    22.             "PreviewType" = "Plane"
    23.             "CanUseSpriteAtlas" = "True"
    24.         }
    25.  
    26.         Cull Off
    27.         Lighting Off
    28.         ZWrite Off
    29.         Blend One OneMinusSrcAlpha
    30.  
    31.         Pass
    32.         {
    33.         CGPROGRAM
    34.             #pragma vertex SpriteVert
    35.             #pragma fragment SpriteFrag
    36.             #pragma target 2.0
    37.             #pragma multi_compile_instancing
    38.             #pragma multi_compile  PIXELSNAP_ON
    39.             #pragma multi_compile  ETC1_EXTERNAL_ALPHA
    40.             #include "Depth.cginc"
    41.         ENDCG
    42.         }
    43.     }
    44. }
    With a lot of messing around, we managed to get the terrain shader working by removing "out depth", however that did not seem to work for the part shader.

    Any help would be really appreciated, i'm getting absolutely spammed with reports of this bug.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Hi!
    If you make a development build on a device where this fails, it will output what problem does it encounter in the logcat.
    This just means that some shaders are not supported on this device.
    Is there anything common between the devices where those shaders don't work?
     
  3. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    We found this error:
    -------- GLSL link error: L0010 Uniform '_WorldSpaceLightPos0' differ on precision

    Any idea what it could be or how could we solve it?


    Full log
    Code (CSharp):
    1. OdinSerializer detected Android architecture 'armv7l' for determining unaligned read/write capabilities. Unaligned read/write support: all=False, float=True => Log
    2. UnityEngine.Logger:Log(LogType, Object)
    3. Sirenix.Serialization.ArchitectureInfo:SetIsOnAndroid(String)
    4. Sirenix.Serialization.UnitySerializationInitializer:Initialize()
    5.  
    6. UnityIAP: Unity Ads not present, Promotional placements not possible => Log
    7. UnityEngine.Purchasing.StandardPurchasingModule:Instance(AppStore)
    8. ۝ڥӒغ:޻أ݀ڕ()
    9.  
    10. Calling android JNI method => Log
    11. UnityEngine.Logger:Log(LogType, Object)
    12. CodeStage.AntiCheat.Genuine.CodeHash.AndroidWorker:Execute()
    13. CodeStage.AntiCheat.Genuine.CodeHash.CodeHashGenerator:GenerateInternal()
    14.  
    15. [ACTk] Obscured Cheating Detector: was started without any callbacks. Please configure Detection Event in the inspector, or pass the callback Action to the StartDetection method. => Warning
    16. UnityEngine.Debug:LogWarning(Object, Object)
    17. CodeStage.AntiCheat.Detectors.ObscuredCheatingDetector:StartDetectionInternal(Action)
    18.  
    19. -------- GLSL link error: L0010 Uniform '_WorldSpaceLightPos0' differ on precision
    20.  
    21. => Error
    22.  
    23. UnityIAP: Unity Ads not present, Promotional placements not possible => Log
    24. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    25.  
    26. UnityIAP: Unity Ads not present, Promotional placements not possible => Log
    27. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    28.  
    29. UnityIAP: Unity Ads not present, Promotional placements not possible => Log
    30. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    31.  
    32. KeyNotFoundException: The given key was not present in the dictionary. => Exception
    33. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <00000000000000000000000000000000>:0)
    34. SFS.Parts.PartTexture.Get_UV (SFS.Parts.Modules.Pipe shape, Line segment, System.Single shapeWidth, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    35. SFS.Parts.Modules.Textures.GetOutput (SFS.Parts.Modules.Pipe shape, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    36. SFS.Parts.Modules.PipePartMesh.Get_UV_Channels (SFS.Parts.Modules.Pipe shape) (at <00000000000000000000000000000000>:0)
    37. SFS.Parts.Modules.PipeMesh.GenerateMesh () (at <00000000000000000000000000000000>:0)
    38. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    39. SFS.Variables.Composed`1[T].op_Addition (SFS.Variables.Composed`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    40. SFS.Parts.Modules.PipePartMesh.I_Setup.Setup () (at <00000000000000000000000000000000>:0)
    41. SFS.Parts.Part.InitializePart () (at <00000000000000000000000000000000>:0)
    42. SFS.Parts.PartsLoader.CreatePart (SFS.Parts.Modules.VariantRef variant) (at <00000000000000000000000000000000>:0)
    43. SFS.Builds.PickGrid.CreateParts (SFS.Parts.Modules.VariantRef[] parts) (at <00000000000000000000000000000000>:0)
    44. SFS.Builds.PickGrid.SetPicklist (SFS.Builds.PickGrid+CollectedPicklist A) (at <00000000000000000000000000000000>:0)
    45. SFS.Builds.PickGrid.Setup () (at <00000000000000000000000000000000>:0)
    46. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    47. SFS.Variables.LocalVariable`1[T].op_Addition (SFS.Variables.LocalVariable`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    48. SFS.Builds.PickGrid.Start () (at <00000000000000000000000000000000>:0)
    49.  
    50. UnityIAP: Unity Ads not present, Promotional placements not possible => Log
    51. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    52.  
    53. KeyNotFoundException: The given key was not present in the dictionary. => Exception
    54. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <00000000000000000000000000000000>:0)
    55. SFS.Parts.PartTexture.Get_UV (SFS.Parts.Modules.Pipe shape, Line segment, System.Single shapeWidth, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    56. SFS.Parts.Modules.Textures.GetOutput (SFS.Parts.Modules.Pipe shape, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    57. SFS.Parts.Modules.PipePartMesh.Get_UV_Channels (SFS.Parts.Modules.Pipe shape) (at <00000000000000000000000000000000>:0)
    58. SFS.Parts.Modules.PipeMesh.GenerateMesh () (at <00000000000000000000000000000000>:0)
    59. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    60. SFS.Variables.Composed`1[T].op_Addition (SFS.Variables.Composed`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    61. SFS.Parts.Modules.PipePartMesh.I_Setup.Setup () (at <00000000000000000000000000000000>:0)
    62. SFS.Parts.Part.InitializePart () (at <00000000000000000000000000000000>:0)
    63. SFS.Parts.PartsLoader.CreatePart (SFS.Parts.Modules.VariantRef variant) (at <00000000000000000000000000000000>:0)
    64. SFS.Builds.PickGrid.CreateParts (SFS.Parts.Modules.VariantRef[] parts) (at <00000000000000000000000000000000>:0)
    65. SFS.Builds.PickGrid.SetPicklist (SFS.Builds.PickGrid+CollectedPicklist A) (at <00000000000000000000000000000000>:0)
    66. SFS.Builds.PickGrid.Setup () (at <00000000000000000000000000000000>:0)
    67. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    68. SFS.Variables.LocalVariable`1[T].op_Addition (SFS.Variables.LocalVariable`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    69. SFS.Builds.PickGrid.Start () (at <00000000000000000000000000000000>:0)
    70.  
    71. KeyNotFoundException: The given key was not present in the dictionary. => Exception
    72. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <00000000000000000000000000000000>:0)
    73. SFS.Parts.PartTexture.Get_UV (SFS.Parts.Modules.Pipe shape, Line segment, System.Single shapeWidth, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    74. SFS.Parts.Modules.Textures.GetOutput (SFS.Parts.Modules.Pipe shape, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    75. SFS.Parts.Modules.PipePartMesh.Get_UV_Channels (SFS.Parts.Modules.Pipe shape) (at <00000000000000000000000000000000>:0)
    76. SFS.Parts.Modules.PipeMesh.GenerateMesh () (at <00000000000000000000000000000000>:0)
    77. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    78. SFS.Variables.Composed`1[T].op_Addition (SFS.Variables.Composed`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    79. SFS.Parts.Modules.PipePartMesh.I_Setup.Setup () (at <00000000000000000000000000000000>:0)
    80. SFS.Parts.Part.InitializePart () (at <00000000000000000000000000000000>:0)
    81. SFS.Parts.PartsLoader.CreatePart (SFS.Parts.Modules.VariantRef variant) (at <00000000000000000000000000000000>:0)
    82. SFS.Builds.HoldGrid.SelectParts (SFS.Input.TouchPosition touchPosition) (at <00000000000000000000000000000000>:0)
    83. SFS.Builds.BuildManager.OnTouchStart (SFS.Input.TouchStartData data) (at <00000000000000000000000000000000>:0)
    84. SingleDelegate`1[T].Invoke (T value) (at <00000000000000000000000000000000>:0)
    85. SFS.Input.TouchInput.TouchStart (System.Int32 fingerId, SFS.Input.TouchPosition touchPosition) (at <00000000000000000000000000000000>:0)
    86. SFS.Input.TouchInput.GetTouchInputs () (at <00000000000000000000000000000000>:0)
    87.  
    88. KeyNotFoundException: The given key was not present in the dictionary. => Exception
    89. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <00000000000000000000000000000000>:0)
    90. SFS.Parts.PartTexture.Get_UV (SFS.Parts.Modules.Pipe shape, Line segment, System.Single shapeWidth, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    91. SFS.Parts.Modules.Textures.GetOutput (SFS.Parts.Modules.Pipe shape, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    92. SFS.Parts.Modules.PipePartMesh.Get_UV_Channels (SFS.Parts.Modules.Pipe shape) (at <00000000000000000000000000000000>:0)
    93. SFS.Parts.Modules.PipeMesh.GenerateMesh () (at <00000000000000000000000000000000>:0)
    94. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    95. SFS.Variables.Composed`1[T].op_Addition (SFS.Variables.Composed`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    96. SFS.Parts.Modules.PipePartMesh.I_Setup.Setup () (at <00000000000000000000000000000000>:0)
    97. SFS.Parts.Part.InitializePart () (at <00000000000000000000000000000000>:0)
    98. SFS.Parts.PartsLoader.CreatePart (SFS.Parts.Modules.VariantRef variant) (at <00000000000000000000000000000000>:0)
    99. SFS.Builds.HoldGrid.SelectParts (SFS.Input.TouchPosition touchPosition) (at <00000000000000000000000000000000>:0)
    100. SFS.Builds.BuildManager.OnTouchStart (SFS.Input.TouchStartData data) (at <00000000000000000000000000000000>:0)
    101. SingleDelegate`1[T].Invoke (T value) (at <00000000000000000000000000000000>:0)
    102. SFS.Input.TouchInput.TouchStart (System.Int32 fingerId, SFS.Input.TouchPosition touchPosition) (at <00000000000000000000000000000000>:0)
    103. SFS.Input.TouchInput.GetTouchInputs () (at <00000000000000000000000000000000>:0)
    104.  
    105. KeyNotFoundException: The given key was not present in the dictionary. => Exception
    106. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <00000000000000000000000000000000>:0)
    107. SFS.Parts.PartTexture.Get_UV (SFS.Parts.Modules.Pipe shape, Line segment, System.Single shapeWidth, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    108. SFS.Parts.Modules.Textures.GetOutput (SFS.Parts.Modules.Pipe shape, UnityEngine.Transform meshHolder, UnityEngine.Vector2 lightDirection) (at <00000000000000000000000000000000>:0)
    109. SFS.Parts.Modules.PipePartMesh.Get_UV_Channels (SFS.Parts.Modules.Pipe shape) (at <00000000000000000000000000000000>:0)
    110. SFS.Parts.Modules.PipeMesh.GenerateMesh () (at <00000000000000000000000000000000>:0)
    111. SFS.Variables.OnChange.Invoke () (at <00000000000000000000000000000000>:0)
    112. SFS.Variables.Composed`1[T].op_Addition (SFS.Variables.Composed`1[T] a, SFS.Variables.OnChange b) (at <00000000000000000000000000000000>:0)
    113. SFS.Parts.Modules.PipePartMesh.I_Setup.Setup () (at <00000000000000000000000000000000>:0)
    114. SFS.Parts.Part.InitializePart () (at <00000000000000000000000000000000>:0)
    115. SFS.Parts.PartsLoader.CreatePart (SFS.Parts.Modules.VariantRef variant) (at <00000000000000000000000000000000>:0)
    116. SFS.Builds.HoldGrid.SelectParts (SFS.Input.TouchPosition touchPosition) (at <00000000000000000000000000000000>:0)
    117. SFS.Builds.BuildManager.OnTouchStart (SFS.Input.TouchStartData data) (at <00000000000000000000000000000000>:0)
    118. SingleDelegate`1[T].Invoke (T value) (at <00000000000000000000000000000000>:0)
    119. SFS.Input.TouchInput.TouchStart (System.Int32 fingerId, SFS.Input.TouchPosition touchPosition) (at <00000000000000000000000000000000>:0)
    120. SFS.Input.TouchInput.GetTouchInputs () (at <00000000000000000000000000000000>:0)
    121.  
    122.  
    I heavily doubt the KeyNotFoundException causes the pink shaders, as they also happen to other completely unrelated parts of the game
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    No, this link error is the culprit.
    I also suppose this happens only on OpenGL ES2 devices, is that right?
    Can you please report this as a bug?
    Also, I don't see your shaders using _WorldSpaceLightPos0... Is it in some .cginc file?
    I might be able to provide a workaround if I see the code that uses it.
     
  5. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Yes it only happens on OpenGL ES2.

    We figure out its this part of the code:
    fixed4 frag(v2f i, out float depth : SV_Depth)
    If we stop using depth, the shader works (That also unfortunately breaks our game render order)

    Currently i'm creating a copy of every shader using depth, asking the users manually if their game is pink, and applying the alternative shaders. Their render order is still broken, but better than a pink screen.

    I would be really happy to know if there is any workaround.
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
  7. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    I found this fix, for anyone that has this problem in the future:

    Code (CSharp):
    1. #if defined(SHADER_API_GLES)
    2.     fixed4 frag(v2f IN) : SV_Target
    3.     {
    4.         // Color texture // Vertice color
    5.         fixed4 c = tex2D(_TextureAtlas, IN.UVQ_0.xy / IN.UVQ_0.z) * IN.color;
    6.  
    7.         // Alpha / Albedo
    8.         c.rgb *= albedo * c.a;
    9.  
    10.         return c;
    11.     }
    12. #else
    13.         fixed4 frag(v2f IN, out float depth : SV_Depth) : SV_Target
    14.     {
    15.         // Color texture // Vertice color
    16.         fixed4 c = tex2D(_TextureAtlas, IN.UVQ_0.xy / IN.UVQ_0.z) * IN.color;
    17.  
    18.         // Alpha
    19.         c.rgb *= albedo * c.a;
    20.  
    21.         // Depth
    22.         #if defined(UNITY_REVERSED_Z)
    23.         depth = IN.UVQ_3.x;
    24.         #else
    25.         depth = 1.0f - IN.UVQ_3.x;
    26.         #endif
    27.  
    28.         return c;
    29.     }
    30. #endif
     
    SlimeProphet likes this.
  8. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Our game uses 2.5d rendering. It was the only way we could make things like this work: upload_2020-6-8_10-0-0.png
    We tried everything, even making them actual 3d models etc
    (Unity does some weird optimization for 3d models where entire model has the same render order)

    If you have any creative idea, we would gladly get rid of this entire depth system.
     
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    I'm not entirely sure what you mean by "things like this" :)
     
  10. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Might be a better example:
    upload_2020-6-8_11-37-5.png
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Why can't you work with separate 3D models here?
     
  12. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    We are not a 100% sure why, but it just did not work.
    Our theory is that for optimization, each rendered mesh has a render order calculated from its distance to camera.

    Either way, #if defined(SHADER_API_GLES) worked
    The backup shader does not have the fancy depth system, but the game is still playable.
     
  13. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
  14. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    Opaque 3D models don't actually care what their render order is in terms of the final image. The whole reason why the depth buffer exists is so that the final image is deterministic regardless of draw order.

    However, if you swapped to using 3D models, but were still using transparent materials / shaders, those generally do not write to the depth buffer, and the draw order matters again, just like any other transparent sprite.
     
  15. Stef_Morojna

    Stef_Morojna

    Joined:
    Apr 15, 2015
    Posts:
    289
    Yes we have transparent textures, the whole system has to be able to handle them.