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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

White matte of alpha texture Not Removed

Discussion in 'Editor & General Support' started by Rachan, Nov 19, 2021.

  1. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    509
    Hi there!

    I update Unity to 2021.2.2f1 already
    and I build my game to iPhone for test
    and this is what I got

    this is from iPhone 12 Pro Max everything seem to be Ok...


    But this is from iPhone 13 Pro Max


    What happen?
    I also enabled Remove Matte (PSD) already But why still have a white edge of every sprite!!!
    and yes I used .PSD image But why before 2021.2.2f there has no problem? and it only happen in iPhone13 Pro Max!!!

    anyone used to have this problem?

    Thanks!!!
     
  2. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    509
    Oh I just see this sprite has been render by my custom shader
    if default shader from Unity is ok

    this is my sprite shader Why this is just happen in Unity 2021.2.2f and iPhone 13 Pro Max?

    Shader "2D/Sprite"{
    Properties{
    _Color ("Tint", Color) = (0, 0, 0, 1)
    _MainTex ("Texture", 2D) = "black" {}
    }
    SubShader{
    Tags{
    "RenderType"="Sprite"
    "Queue"="Transparent"
    }
    Blend SrcAlpha OneMinusSrcAlpha
    ZWrite off
    Cull off
    Pass{
    CGPROGRAM
    #include "UnityCG.cginc"
    #pragma vertex vert
    #pragma fragment frag
    sampler2D _MainTex;
    float4 _MainTex_ST;
    struct appdata{
    float4 vertex : POSITION;
    float2 uv : TEXCOORD0;
    fixed4 color : COLOR;
    };
    struct v2f{
    float4 position : SV_POSITION;
    float2 uv : TEXCOORD0;
    fixed4 color : COLOR;
    };
    v2f vert(appdata v){
    v2f o;
    o.position = UnityObjectToClipPos(v.vertex);
    o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    o.color = v.color;
    return o;
    }
    float alphaTmp = 0;
    fixed4 frag(v2f i) : SV_TARGET{
    fixed4 colTexture = tex2D(_MainTex, i.uv);
    alphaTmp = colTexture.a;
    float blender = i.color.a;

    colTexture = lerp(colTexture, colTexture,blender);
    colTexture = lerp(colTexture, i.color,blender);
    colTexture.a = alphaTmp;
    return colTexture;
    }
    ENDCG
    }
    }
    }