Transparent shaders > rendertexture with alpha

Hi experts!

I would like to compose a scene with several planes, having a PNG texture with transparency (not just cutout, true alpha).

This scene has a camera rendering to a Rendertexture containing alpha.

In another scene, I would like to be able to put a plane with that rendertexture, in front other planes (eventually also containing alpha, etcetera). This should render to a rendertexture with correct alpha again.

Graphical explanation:

What shaders would I need to be able to do this? My current transparent shader doesn’t work with every setting I tried on the camera for clearing the background.

My shader:

Shader "Mode/Alpha with Mask" {
    Properties {
      _MainTex ("Texture", 2D) = "white" {}
      _BumpMap ("Texture", 2D) = "white" {}
      _Color ("Main Color", Color) = (1.0, 1.0, 1.0, 1.0)
      _AddColor ("Add Color", Color) = (0.0, 0.0, 0.0, 1.0)
      _Mode("Mode", float) = 0.0
    }
    SubShader {
      Tags { "RenderType" = "transparent" "Queue"="transparent"}
      ZWrite Off
      //Lighting Off
      CGPROGRAM
      #pragma target 3.0
      #pragma surface surf Unlit noambient alpha
      struct Input {
        float2 uv_MainTex;
        float2 uv_BumpMap;
        fixed4 _Color;
        fixed4 _AddColor;
        float _Mode;
      };
      sampler2D _MainTex;
      sampler2D _BumpMap;
      fixed4 _Color;
      fixed4 _AddColor;
      float _Mode;
        inline half4 LightingUnlit (SurfaceOutput s, half3 lightDir, half atten) {
            float4 c;
            c.rgb = s.Albedo;
            c.a = s.Alpha;
            return c;
        }

        inline half4 LightingUnlit_PrePass (SurfaceOutput s, half4 light) {
            float4 c;
            c.rgb = s.Albedo;
            c.a = s.Alpha;
            return c;
        }
     
     void surf (Input IN, inout SurfaceOutput o) {
          fixed4 tex = tex2D (_MainTex, IN.uv_MainTex);
          float4 c = tex2D(_BumpMap, IN.uv_BumpMap);
        float3 output = tex.rgb * _Color.rgb;
        float grey = (c.r + c.g + c.b) / 3.0;
        float alpha = tex.a * _Color.a * grey * c.a;
        o.Alpha = alpha;
        o.Emission = output.rgb + _AddColor.rgb;
      }
     
     
      ENDCG
    }
    Fallback "Unlit/Texture"
  }

Not entirely sure since I don’t have much experience with surf shaders(they end up as vert/frag anyway) but I don’t see you indicating Blend mode.

Thanks for your reply, I’ll dive into the world of ‘blend modes’ to see if that’s something I’ve missed! :slight_smile: