Fragment shader shows alpha, surface shader doesn't

I have 2 shaders that do the same, which is nothing… just pass the color.

As a fragment shader

Shader "EffectBakers/FogBaker"
    {
        Properties
        {
            [PerRendererData] _MainTex ("Color (RGB) Alpha (A)", 2D) = "black" {}
            [MaterialToggle] PixelSnap( "Pixel snap", Float) = 0
  
            [HideInInspector]_FogTexture( "Fog Ramp Texture", 2D) = "black" { }
            [HideInInspector]_01FogDepthVerticals( "Linear Depth 01 And Verticals", Vector) = (0.0, 0.0, 0.0, 0.0)        
            [HideInInspector]_IsWarm( "Warm texture or Cold texture", Range(0,1)) = 0
        }
  
        SubShader
        {
            Tags
            {
                "Queue"="Transparent"
                "IgnoreProjector"="True"
                "RenderType"="Transparent"
                "PreviewType"="Plane"
                "CanUseSpriteAtlas"="True"
            }
  
            Cull Off
            Lighting Off
            ZWrite Off
            Fog { Mode Off }
            Blend One OneMinusSrcAlpha
  
            Pass
            {
            CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #pragma multi_compile DUMMY PIXELSNAP_ON
                #include "UnityCG.cginc"
  
                struct appdata_t
                {
                    float4 vertex   : POSITION;
                    float2 texcoord : TEXCOORD0;
                };
  
                struct v2f
                {
                    float4 vertex   : SV_POSITION;
                    half2 texcoord  : TEXCOORD0;
                };
  
                fixed4 _Color;
  
                v2f vert(appdata_t IN)
                {
                    v2f OUT;
                    OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
                    OUT.texcoord = IN.texcoord;
                    #ifdef PIXELSNAP_ON
                    OUT.vertex = UnityPixelSnap (OUT.vertex);
                    #endif
  
                    return OUT;
                }
  
                sampler2D _MainTex;
  
                fixed4 frag(v2f IN) : SV_Target
                {
                    fixed4 c = tex2D(_MainTex, IN.texcoord);
                    c.rgb *= c.a;
                    return c;
                }
            ENDCG
            }
        }
    }

And as a surface Shader:

Shader "EffectBakers/FogBaker"
        {
            Properties
            {
                _MainTex ("Color (RGB) Alpha (A)", 2D) = "white" {}
                _Color("Tint", Color) = (1, 1, 1, 1)
                [MaterialToggle] PixelSnap( "Pixel snap", Float) = 0
      
                [HideInInspector]_FogTexture( "Fog Ramp Texture", 2D) = "black" { }
                [HideInInspector]_01FogDepthVerticals( "Linear Depth 01 And Verticals", Vector) = (0.0, 0.0, 0.0, 0.0)        
                [HideInInspector]_IsWarm( "Warm texture or Cold texture", Range(0,1)) = 0
            }
      
            SubShader
            {
                Tags
                {
                    "Queue"="Transparent"
                    "IgnoreProjector"="True"
                    "RenderType"="Transparent"
                    "PreviewType"="Plane"
                    "CanUseSpriteAtlas"="True"
                }
      
                Cull Off
                Lighting Off
                ZWrite Off
                Fog { Mode Off }
                Blend One OneMinusSrcAlpha
      
                CGPROGRAM
                #pragma surface surf Lambert vertex:vert nofog keepalpha
                #pragma target 3.0
                #pragma multi_compile _PIXELSNAP_ON 
      
                sampler2D _MainTex;     
      
                fixed4 _Color;     
      
                struct Input
                {
                    float2 uv_MainTex ;
                    float3 worldPos;
                } ;
      
              
                void vert( inout appdata_full v, out Input o )
                {
                    #if defined( PIXELSNAP_ON )
                        v.vertex = UnityPixelSnap(v_.vertex);
                    #endif
      
                        UNITY_INITIALIZE_OUTPUT(Input, o);
                    o.worldPos = mul( _Object2World, v.vertex );
                }
      
                sampler2D _FogTexture;  
                fixed4 _01FogDepthVerticals;
                int _IsWarm;
      
      
                void surf(Input i, inout SurfaceOutput o)
                {
                    fixed4 color = tex2D( _MainTex, i.uv_MainTex );      
                  
                    o.Albedo = color.rgb * color.a;
                    o.Alpha = color.a;
                }
                ENDCG
            }
      
            FallBack "Transparent/Cutout/VertexLit"
        }

why the fragment shader displays the sprite with alpha channel and no problems, but the surface one shows the transparency as black and everything is opaque?

Thanks for the help.

Try

#pragma surface surf Lambert vertex:vert nofog alpha:premul

instead of keepalpha. As for why that works and the other doesn’t … I don’t have a good answer.

Thanks for the help.

alpha:premul shows nothing but black… (Not even all transparent)

The surface shader is using a Lambert lighting model. Do you have no lighting in your scene? If you don’t want to have lighting do anything there’s no reason to use a surface shader.

It’s actually a baker, I Blit a texture to get a new one with some process and then use it in the game, so I don’t need to take the lightning in account at all. I’ll use a fragment shader, but I would like to know why a surface shader doesn’t have alpha channel in this case.