Post processing "truns off" camera's solid color alpha

Hello all !
I’m having and issue with my render texture and post processing asset from Unity (and also with the camera).

So, I have 2 Cameras in my game, and one is only rendering my characters. And I want this camera to have post process effect on it. I set up like this:
My camera’s Clear flag is Solid color and is (0,0,0,0)
It renders into a Render texture
I apply this render texture to a raw image on my canvas

it works perfectly, with only my character showing until I had post process behavior and select things like Bloom, Anti-Alliasing and Color Grading. If I activate one of these, it’s like there is no more transparency in my solid color, it’s always there !

How can I have Solid Color transparency AND post process at the same time ?

Thanks a lot !

Thibault

2 Likes

I think i had kind of the same issue, here’s a link to my thread:

After building the app 100 times, i discovered it was the post processing that was messing with my rendered textures :confused: hope someone will find a way to fix all of this.

1 Like

Hiya, i know its an old thread but there is a fix for this in the Post Processing Stack V1.

At the end of the PostFX Uber shader it simply returns 1 for alpha, we can sample the original alpha and return that instead. This is the original:

Just replace it with:

return half4(color, tex2D(_MainTex, uv).a);

However Anti Aliassing wont work, for FXAA it will clear the alpha again and for TAA it wont render at all. Perhaps you can simply upscale the rendertexture.

I believe the v2 stack has a fix for this, there are some defines regarding AA and alpha.

6 Likes

I rarely post here but this was a lifesaver, thanks!

1 Like

It seems there are some configs which enable to get the alpha with PostProcess Stack 2 but I cannot find them.
I have got a project in which alpha is used (to apply the render texture with Bloom on it to a RawImage/canvas rendered by a non post process camera) and everything works well.
I did another project with the same configuration for player and quality settings (I hope, I checked and did not see differences but I may have forgotten something) with the elements imported from the previous project. This projects fails to render the texture with alpha on my UI. Have you got any idea to fix that (Uniyt 2019.2 + Post Process Stack 2.1.7) ?

yeah i’m also interested

Disabling HDR fixed it for me ! Hope this will help.

1 Like

Can’t believe this actually worked, thank you!
It is also important to set anti-aliasing on Post Process Layer to FXAA and toggle the “Keep Alpha” button.

Perfect, thanks!

Thanks so much for this! In URP 10.4.0, the syntax has changed, you’ll now want:

return half4(color, SAMPLE_TEXTURE2D_X(_SourceTex, sampler_LinearClamp, uv).a);
3 Likes

It works, thx!

1 Like

Is there anyone know how can I fix this on v2?
It looks like all of the solutions are not affectable.

Hello, I have a similar problem but with v2.
On v2, and if the platform is iOS or Android, my render texture’s alpha lost when post-process layer is enabled. However, if the platform is PC, the alpha just works well.
Is there any setting we can adjust to make alpha work also in iOS and Android platforms?

1 Like

This is absolute gold! Thanks so much for this

For urp, change PostFX Uber shader works,
you can do the follow, to force UniversalRendererData use new Uber shader.

  1. create new shader, copy and change Uber shader
  2. cretae new Custom PostProcessData, open it with any text Editor
  3. find " uberPostPS: {fileID: 4800000, guid: …}", replace guid with your new shader’s guid
  4. remember change UniversalRenderData’s PostProcessData to your new Custom PostProcessData

dtaddis’ approach worked for me months later (Unity 2022.3.32f1, URP 14.0.11), but had to use updated variable names in the copy of UberPost.shader:

return half4(color, SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp, uv).a);

ShowMeMore’s answer also contained important next-steps. Note: Once you create your own PostProcessData, if you do not want to edit GUIDs directly in text files, you can use “Debug View” in the Inspector to access the Shaders through the Unity GUI.