We render to a render texture to get the player model rendered over the UI. This worked in the old pipeline by setting the clear colour to fully transparent.
In the new pipeline this doesn’t see to work:
Is there a hidden setting to do this?
We render to a render texture to get the player model rendered over the UI. This worked in the old pipeline by setting the clear colour to fully transparent.
In the new pipeline this doesn’t see to work:
Is there a hidden setting to do this?
Just set the alpha of background color of the camera to 0
I am doing that
Setting the alpha of the background color to 0 worked until Unity 2018.3, in the HDRP for Unity 2019.1 it doesn’t work (or at least it didn’t work last time I tried it, 2 months ago).
I thought it was a bug and I sent a bug report to Unity, they answered me: “we plan to use the alpha channel of the color buffer for future features, we cannot support the output of alpha channel in a render texture. For now, the issue will be present but you can expect new features that will account for the desired behavior in this case”
You can also find my bug report in the issue tracker: Unity Issue Tracker - [HDRP] Camera Color Alpha variable is ignored when using HDRP 5.10.0
If someone has a fast workaround would be fantastic, currently I’m stuck with Unity 2018.3 for this problem.
I’ve managed to hack it for now, it’s not ideal but I wrote a greenscreen shader which sets alpha to 0 if it’s bright green. It’s not ideal but it’s a stop gap until there’s a real solution.
We’re creating prerendered images, so I’m rendering the camera twice: once with black and once with white. Then I compare the pixels … if the black background has a pixel == to black and the white background == white, then I know its pure transparent. If both black and white textures have the same pixel color, I know its pure opaque. Im faking alpha value by just taking the difference from the grayscale values. Its good enough to make my textures work.
But yes. This is absolutely stupid. Really … there should be a better way of handling this. Considering Unity is moving to doing more things than just games, this feels like a step backwards … hopefully they actually give us a built in way to get the real alpha values per pixel for a transparent background. I don’t care how, it should just be an option somewhere, some how.
I just ran into this. Using universal it looks fine in the editor but doesn’t work in a build… sigh
Could you share the shader and what you’re attaching it to?
I render to a RT with a fixed colour background, then render that RT via the UI system using a custom shader that draws transparent if matches that colour.
Yeah that’s the general advice I’ve been dishing out too, it’s cos HDRP just reserves camera alpha if I’m not mistaken, assuming you’re on HDRP that is and not builtin or other.
That’s exactly what I ended up doing! Thanks!
I am having a similar issue with RTT not writing alpha in HDRP.
This is what I found, and maybe if we raise enough stink, they will fix this and make it an opt in feature, or soemthing
Any update here? The issuetracker is closed for this one, but i still can’t find a solution from unity in the final 19.3 release.
My list of roadblocks for HDRP is not getting any shorter. I don’t want workarounds for what were standard features for years.
@garryjnewman @karl_kent @ventzs
To use alpha with render texture you need to be using a version of HDRP with 2019.3. So HDRP 7.x.x then you go to the HDRP asset and change the Color Buffer Format to R16, By default all projects are using R11.
and do not using Antialiasing and bloom post process, will work fine
Could you tell how did you do thst?
Any news about this ?
It’s been possible for a long time now - https://discussions.unity.com/t/747578/14
This is for HDRP, and for URP ?
Hey all! I’m pretty invested in URP, and when I got to making render textures… this totally bummed me out. This problem took an hour or two out of my dev time :(. But thanks to garry’s cool workaround of “green screening” the render texture. I took that approach… here is my 2D Sprite Lit Shader graph that I apply to Raw Image UI… [it’s weird I couldn’t get 2D Unlit shader to work here… but it’s probably something I’m doing…] I guess if you have green, you could apply another color too! I’ve seen much more complex logic too… but this what I did just to get started. Good luck devs!