Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

RenderTexture Alpha Issue..

Discussion in 'Unity UI & TextMesh Pro' started by guy_rabiller, May 28, 2018.

  1. guy_rabiller

    guy_rabiller

    Joined:
    Mar 22, 2018
    Posts:
    8
    Hi,

    I have a Canvas (Screen Space - Camera) and some Sprites, so most of the Canvas space is empty, ie, transparent. Then from the Render Camera, I render to a RenderTexture.

    Clear flags is a Solid black Color, with Alpha set to 0.

    Now, when I try to use this RenderTexture in another Canvas (Screen Space - Overlay) through a RawImage, there is no transparency what so ever, I only get my original sprites with a black background. I can't see through. I've tried to use the "Sprite-Default" material with the RawImage component but that does not help which makes me think there is no alpha in the RenderTexture, or the 0 Alpha set from the Camera solid color is not taken into account.

    What am I doing wrong ?

    Thanks,
    Guy.
     
  2. guy_rabiller

    guy_rabiller

    Joined:
    Mar 22, 2018
    Posts:
    8
    Anyone ? I can't believe being the only one having this issue, it is so easy to reproduce.
    It is a showstopper for me, can move forward in my project because of this.
    Is this a known bug ? Is there a workaround ?
     
  3. cleonsucks

    cleonsucks

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    5
    100% Opacity:



    50% Opacity:



    0% Opacity:

     
  4. cleonsucks

    cleonsucks

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    5
    Render Texture Settings:

     
  5. guy_rabiller

    guy_rabiller

    Joined:
    Mar 22, 2018
    Posts:
    8
    Thanks a lot for your input.

    I've checked my settings and I have exactly the same as yours, and it still does not work.

    Then I just realized I'm also using the "Post Processing Behavior" script on the UI Camera, the one that renders the texture. And for some reason, it destroys the alpha information. If I disable the "Post Processing Behavior" script then everything works correctly.

    Not sure if it is by design or if it is a bug.
     
  6. cleonsucks

    cleonsucks

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    5
    Hi Guy,

    It depends on which post processing effect you have active.
    The following ones will look correct with transparency: Fog, Ambient Occlusion, Screen Space Reflection and Motion Blur. The others operate on the entire texture.
    A way to get what I think you're after would be to clear the UI Camera to Skybox instead. Then the effect will also be applied to the portion of the Skybox shown in the Render Texture though.
    This is by design.
     
  7. guy_rabiller

    guy_rabiller

    Joined:
    Mar 22, 2018
    Posts:
    8
    Thanks again for the info.
    Perhaps a solution would be to have a script that "record" the alpha channel at some point of the stack then reapply it as the last step of the filter stack, overriding whatever has been done to the alpha channel. That would solve the issue.
    By any chance, do you know if such a script exist ?
     
  8. cleonsucks

    cleonsucks

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    5
    Hi Guy,

    I'm not aware of that, but the development of the Post Processing stack is open source on GitHub.
    You can follow it here and play around with it.
     
  9. guy_rabiller

    guy_rabiller

    Joined:
    Mar 22, 2018
    Posts:
    8
    Right, indeed.

    Thanks again.