Strange behaviour with surface shader and Alpha scene layer

Hi folks,

Well, I’m trying to write a shader that I can use with render To texture and I’m facing a weird problem.

With this code, the alpha layer of the scene shows the alpha of the texture :

Shader "TestGUI" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Diffuse", 2D) = "white" {}
    _RimPower ("Rim Power", Range(0.1,3.0)) = 3.0
}
SubShader {
    Tags { "RenderType"="Opaque" }
    LOD 200

CGPROGRAM
#pragma surface surf Lambert

sampler2D _MainTex;
float4 _Color;
float _RimPower;

struct Input {
    float2 uv_MainTex;
    float3 viewDir;
};

void surf (Input IN, inout SurfaceOutput o) {

    half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;
    o.Alpha = c.a;
    
}
ENDCG
}

Fallback "VertexLit"
}

And with this code ( simply 1 line added, which doesn’t interfere with the result), I obtain a totally opaque alpha :

Shader "TestGUI" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Diffuse", 2D) = "white" {}
    _RimPower ("Rim Power", Range(0.1,3.0)) = 3.0
}
SubShader {
    Tags { "RenderType"="Opaque" }
    LOD 200

CGPROGRAM
#pragma surface surf Lambert

sampler2D _MainTex;
float4 _Color;
float _RimPower;

struct Input {
    float2 uv_MainTex;
    float3 viewDir;
};

void surf (Input IN, inout SurfaceOutput o) {

    half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;
    o.Alpha = c.a;
    half rim = 1.0 - saturate(dot (normalize(IN.viewDir), IN.Normal));
    
}
ENDCG
}

Fallback "VertexLit"
}

I really don’t understand how the alpha layer works…

Maybe this last line is asking too much from your graphics device, that is using the VertexLit fallback?

I just tested these two shaders (copy/paste) and I just got this error with the second one:

Shader error in ‘TestGUI’: Program ‘surf’, expression left of .“Normal” is not a struct or array at line 28