Topic: Map render white on Iphone 12 or above

Hello,

I am developing an App with your plug-in version 3.7.15.1 on Unity 2020.3.22, however on Iphone 12 or above and also on the xcode simulator the map shows complete white.

I've alredy tried to substitute the tileset shader with the Legacy one and, indeed, it works. My question is if you are going to solve this bug in future versions of the plug-in.

Thank you in advance!

Re: Map render white on Iphone 12 or above

Hello.

Unfortunately, I don't think I can fix this because I don't have much experience in shader development.
As a workaround, you can try using URP.
The shader for URP will most likely work correctly on any platform.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Map render white on Iphone 12 or above

Hello, thank you very much for your answer!

However, I know a little about shader and I've tried to find out a solution or maybe the source of the problem.
As I noticed the problem was only on the Iphone that used metal as rendering so the problem was in there.

In your tileset shader the Z-Write directive was missing, so I've tried to recreate your shader in Amplify Shader fixing the Z-Write adding in the subshader:

ZWrite Off
ZTest LEqual

I've read online that Unity has some issues when translating the code from HSLS to Metal, causing some issues in particular with transparent shaders and Zwrite issues related.

Here is the Shader Code (It is generated by Amplify Shader so some variables names are odd, but you can modify them as you want):

Shader "Map"
{
    Properties
    {
        _MainTex("MainTex", 2D) = "white" {}
        _OverlayBackTex("OverlayBackTex", 2D) = "black" {}
        _TrafficTex("TrafficTex", 2D) = "black" {}
        _OverlayFrontTex("OverlayFrontTex", 2D) = "black" {}
        _OverlayBackAlpha("OverlayBackAlpha", Range( 0 , 1)) = 1
        _OverlayFrontAlpha("OverlayFrontAlpha", Range( 0 , 1)) = 1
        _Color("Color", Color) = (1,1,1,1)
    }

    SubShader
    {
        Tags{ "RenderType" = "Custom"  "Queue" = "Transparent+0" "IgnoreProjector" = "True" "IsEmissive" = "true"  }
        Cull Back
        ZWrite Off
        ZTest LEqual
        CGPROGRAM
        #pragma target 3.0
        #pragma surface surf Unlit keepalpha noshadow
        struct Input
        {
            float2 uv_texcoord;
        };

        uniform sampler2D _MainTex;
        uniform float4 _MainTex_ST;
        uniform sampler2D _OverlayBackTex;
        uniform float4 _OverlayBackTex_ST;
        uniform float _OverlayBackAlpha;
        uniform sampler2D _TrafficTex;
        uniform float4 _TrafficTex_ST;
        uniform sampler2D _OverlayFrontTex;
        uniform float4 _OverlayFrontTex_ST;
        uniform float _OverlayFrontAlpha;
        uniform float4 _Color;

        inline half4 LightingUnlit( SurfaceOutput s, half3 lightDir, half atten )
        {
            return half4 ( 0, 0, 0, s.Alpha );
        }

        void surf( Input i , inout SurfaceOutput o )
        {
            float2 uv_MainTex = i.uv_texcoord * _MainTex_ST.xy + _MainTex_ST.zw;
            float4 tex2DNode1 = tex2D( _MainTex, uv_MainTex );
            float4 appendResult12 = (float4(tex2DNode1.r , tex2DNode1.g , tex2DNode1.b , 0.0));
            float2 uv_OverlayBackTex = i.uv_texcoord * _OverlayBackTex_ST.xy + _OverlayBackTex_ST.zw;
            float4 tex2DNode3 = tex2D( _OverlayBackTex, uv_OverlayBackTex );
            float4 appendResult11 = (float4(tex2DNode3.r , tex2DNode3.g , tex2DNode3.b , 0.0));
            float4 lerpResult9 = lerp( appendResult12 , appendResult11 , ( tex2DNode3.a * _OverlayBackAlpha ));
            float2 uv_TrafficTex = i.uv_texcoord * _TrafficTex_ST.xy + _TrafficTex_ST.zw;
            float4 tex2DNode6 = tex2D( _TrafficTex, uv_TrafficTex );
            float4 appendResult16 = (float4(tex2DNode6.r , tex2DNode6.g , tex2DNode6.b , 0.0));
            float4 lerpResult13 = lerp( lerpResult9 , appendResult16 , tex2DNode6.a);
            float2 uv_OverlayFrontTex = i.uv_texcoord * _OverlayFrontTex_ST.xy + _OverlayFrontTex_ST.zw;
            float4 tex2DNode7 = tex2D( _OverlayFrontTex, uv_OverlayFrontTex );
            float4 appendResult18 = (float4(tex2DNode7.r , tex2DNode7.g , tex2DNode7.b , 0.0));
            float4 lerpResult17 = lerp( lerpResult13 , appendResult18 , ( tex2DNode7.a * _OverlayFrontAlpha ));
            o.Emission = ( lerpResult17 * _Color ).xyz;
            o.Alpha = ( _Color.a * tex2DNode1.a );
        }

        ENDCG
    }
Hope it can be of help!

Re: Map render white on Iphone 12 or above

Thanks for your investigation.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

5 (edited by tbuerven 2022-12-21 15:45:03)

Re: Map render white on Iphone 12 or above

Thank you for your messages! Also had the problem that on some combinations of iphone and iOS version, the map renders only a white background. I have updated now to version 3.8., has this bug been taken into account meanwhile?

Thank you!

Update: Unity 2020.3.241f, iphone XS Max. iOS Version 16.2 still the problem, map is not shown, only a white background.
works on iPhone 7 and iOS 15.1

Re: Map render white on Iphone 12 or above

Hello.

No, this fix will not be included, because as far as I remember in the summer I tested it and it could cause problems on other platforms.
Try using the fix from post #3, or use URP.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.