Why Camera clear color alpha channel is ignored?

Dear community

I’m struggling to get camera to use alpha channel of clear color. It looks to me it doesn’t matter what you set clear color alpha value to, unity will still use 255 instead.

This is primarily for render to texture. I want to use an off-screen render camera to render something to a texture. I need the background of my render texture to remain transparent when this render texture is rendered back into the main scene (a quad with simple material referencing my render texture).

These are my steps so far:

  1. Create a RenderTexture asset, 2D, ARGB32
  2. Create a Camera and set it to render to my RenderTexture
  3. Set camera Clear Flags to Solid Color
  4. Set Background color to say RGBA(255,0,0,0), note alpha=0

Now if I check my render texture in inspector it is showing solid red background as if my clear color was RGBA(255,0,0,255). The non-trasparent background makes it impossible to use as an overlay on top of some other content :frowning:

Any ideas please?

I had to do this before… my solution was to not render transparent, but to render it magenta… the old school color for transparency.
Then I ran a script to search through the texture2d pixels… and swap out the pixels for my desired transparent color.

Hi guys,
@voidcoder I’m facing the same problem for others reasons but I was wondering you’ll find a way to do that without killing perfs ?