Custom Shader Blending Works in Editor but does not work in Runtime

I have created a very simple 16 color palette shader for a 3d nes simulators. I’m using Blending so that objects wont be completely hidden by other objects. Everything seems fine in Editor mode as you can see in the clip below:

But when i built and run on Window Platform, every pixel becomes solid. Alpha blending does not work anymore. I post the shader code here hopping that someone can help.
Thank you

Shader "Custom/16 Colors Palette" {
    Properties{
        _Color0("Color0", Color) = (0,0,0,0)
        _Color1("Color1", Color) = (1,0,0,1)
        _Color2("Color2", Color) = (0,1,0,1)
        _Color3("Color3", Color) = (0,0,1,1)
        _Color4("Color4", Color) = (0,0,0,0)
        _Color5("Color5", Color) = (1,0,0,1)
        _Color6("Color6", Color) = (0,1,0,1)
        _Color7("Color7", Color) = (0,0,1,1)
        _Color8("Color8", Color) = (0,0,0,0)
        _Color9("Color9", Color) = (1,0,0,1)
        _Color10("Color10", Color) = (0,1,0,1)
        _Color11("Color11", Color) = (0,0,1,1)
        _Color12("Color12", Color) = (0,0,0,0)
        _Color13("Color13", Color) = (1,0,0,1)
        _Color14("Color14", Color) = (0,1,0,1)
        _Color15("Color15", Color) = (0,0,1,1)
    }

        SubShader{

            Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
            Cull Back
            Blend SrcAlpha OneMinusSrcAlpha
            Lighting Off        // On | Off

            Pass{
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag alpha:blend

                uniform fixed4 _Color0,_Color1,_Color2,_Color3,_Color4,_Color5,_Color6,_Color7,_Color8,_Color9,_Color10,_Color11,_Color12,_Color13,_Color14,_Color15;

                struct vi {
                    fixed4 pos : POSITION;
                    fixed4 color : COLOR;
                };
   
                struct v2f {
                    fixed4 pos : SV_POSITION;
                    fixed4 color : COLOR;
                };


                v2f vert(vi i)
                {
                    v2f o;
                    o.pos = mul(UNITY_MATRIX_MVP, i.pos);

                    if (i.color.r < 0.49)
                    {
                        if (i.color.r < 0.24)
                        {
                            if (i.color.r < 0.115)
                            {
                                if (i.color.r < 0.0525)
                                    o.color = _Color0;
                                else
                                    o.color = _Color1;
                            }
                            else
                            {
                                if (i.color.r < 0.1775)
                                    o.color = _Color2;
                                else
                                    o.color = _Color3;
                            }
                        }
                        else
                        {
                            if (i.color.r < 0.365)
                            {
                                if (i.color.r < 0.3025)
                                    o.color = _Color4;
                                else
                                    o.color = _Color5;
                            }
                            else
                            {
                                if (i.color.r < 0.4275)
                                    o.color = _Color6;
                                else
                                    o.color = _Color7;
                            }
                        }
                    }
                    else
                    {
                        if (i.color.r < 0.74)
                        {
                            if (i.color.r < 0.615)
                            {
                                if (i.color.r < 0.5525)
                                    o.color = _Color8;
                                else
                                    o.color = _Color9;
                            }
                            else
                            {
                                if (i.color.r < 0.6775)
                                    o.color = _Color10;
                                else
                                    o.color = _Color11;
                            }
                        }
                        else
                        {
                            if (i.color.r < 0.865)
                            {
                                if (i.color.r < 0.8025)
                                    o.color = _Color12;
                                else
                                    o.color = _Color13;
                            }
                            else
                            {
                                if (i.color.r < 0.9275)
                                    o.color = _Color14;
                                else
                                    o.color = _Color15;
                            }
                        }
                    }

                    return o;
                }

                fixed4 frag(v2f i) : COLOR
                {
                    return i.color;
                }
                ENDCG
            }
        }
}

I could be way off on this one but have you tried adding a pragma target. ie ‘#pragma target 3.0’ for instance.

Scroll down to ‘Shader Target’ to see a full list.

1 Like

Thank you for the suggestion. I have tested it but no available.