Search Unity

HDRP camera not writing alpha channel to render texture

Discussion in 'General Graphics' started by sebastianzander, Sep 8, 2019.

  1. sebastianzander

    sebastianzander

    Joined:
    Mar 22, 2018
    Posts:
    37
    For a project my team and I want to create a minimap that is situated under a circular UI image mask. The background of the minimap itself shall be transparent to eventually make it look like a holographic projection into the heads up display. Today I discovered that with HDRP the minimap camera doesn't seem to write the alpha values from the clear/background color into the render texture. The actual clear color (RGB) is written but not the alpha part. I tried different render texture formats (basically tried every format with an "A" in it) and also switched the Color Buffer Format to R16G16B16A16 but that didn't make a difference. I also made sure to set Volume Layer Mask of the minimap camera to Nothing, but I also tried to set it to a special minimap layer with a special scene settings volume that doesn't use a sky.

    I know that it worked with the normal (old) rendering pipeline so I created a test project to verify that. Here you can see a comparison of my test project (old rendering pipeline above and HDRP below; project was simply copied and upgraded to use HDRP) with both the scene view and the render texture's alpha channel in the inspector's preview panel (please see attached screenshot).

    We are building for Windows PC and this happens in both scene view as well as game view. Any ideas?
     

    Attached Files:

  2. karl_kent

    karl_kent

    Joined:
    Feb 1, 2018
    Posts:
    10
    I am Also having this issue of Alpha Channel Not written to for an RTT, Only difference Im trying to render UI to an RTT.
     
  3. lozfight

    lozfight

    Joined:
    Sep 2, 2012
    Posts:
    5
    I'm having a similar problem (in LWRP though, and only happening in the build, not in the editor).
    https://forum.unity.com/threads/transparency-issue-with-rawimage-render-target.739604/

    First of all: are you using a RenderPipelineAsset? Check if the "Opaque texture" checkbox is checked. If you want to keep it on its ok, yoo can override that configuration per camera. Make sure that the camera that is rendering the cube has that optin set to "Off".

    Second: Are you using a custom renderer? (setup in the RenderPipelineAsset) If so, test with an empty default one to see if it works.

    Right now I'm struggling with that custom renderer. As soon as I add a render feature the alpha is gone. I hope someone with more expertise takes a look at this in case its somethng easy to set up from here.

    Please let me know if it works. I haven't tested this issue in HDRP but I guess the problem could be similar.
     
  4. sebastianzander

    sebastianzander

    Joined:
    Mar 22, 2018
    Posts:
    37
    Thank you for your input. I do use a Render Pipeline Asset. I tried to disable "Opaque texture" for my minimap camera (the one rendering the red cube). It didn't make any difference at all. In my actual project (rather than the test project above) I am using opaque objects as well on top of a transparent world map. So this couldn't be viable option anyway. You can see what look I try to achieve in the attached image.

    No, I do not use a custom renderer. As I wrote before I simply converted/upgraded the test project to use HDRP without any further change in settings. It has to be bug.

    Are bug reports even caught by the developer here in the forums or would I have to report a bug specifically somewhere else?
     

    Attached Files:

  5. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    Near as I can tell this is not a bug, but an intended feature. They are "reserving" alpha in RTT for some future use. Which, of course, is a really bad idea. We all need to raise this issue as loudly as possible because someone over there is not understanding how important this is.
     
    valentinwinkelmann likes this.
  6. sebastianzander

    sebastianzander

    Joined:
    Mar 22, 2018
    Posts:
    37
    Thank you for your reply nsxdavid. I'm toying with the idea of submitting a bug report nonetheless. In any case, they should provide a workaround. My current workaround basically consists of a custom UI shader in which I do some very basic chroma keying and constructing my alpha from the used colors. But this approach limits me in both quality and the colors that I can use in the actual UI image.
     
  7. nsxdavid

    nsxdavid

    Joined:
    Apr 6, 2009
    Posts:
    476
    @sebastianzander This is the thread where I brought this issue up:

    https://forum.unity.com/threads/alpha-in-render-texture-must-be-alpha.746405/#post-4972694

    And the official reply is at once encouraging and discouraging. In short, they are adding alpha support for render targets in HDRP 7.1.1 (2019.3 b4)... HOWEVER (and this is where it falls apart)..... there are constraints. And these constraints SUCK. Follow thread and post your support for them getting their act together on the alpha channel thing. It really needs some emphasis.
     
    CaseyHofland likes this.
  8. spr1ngd

    spr1ngd

    Joined:
    Oct 17, 2019
    Posts:
    3
    Set HDRenderPipelineAsset->Rendering->Color Buffer Format from R11G11B10 to R16G16B16A16,then you can read alpha channel from RT.
     
  9. gothmommysim

    gothmommysim

    Joined:
    Jul 12, 2017
    Posts:
    2
    thank you so much i was trying to figure this out for hours...
     
  10. Caparrini

    Caparrini

    Joined:
    Jun 21, 2017
    Posts:
    65
    I've been going around for hours with this issue. The most bizarre thing is that I started a new HDRP project from scratch with the same version, and I copied all the HDRPPipelineAsset, VolumeProfiles, etc.. to the new project, and the render texture was working with Alpha perfectly with the color buffer set on R11G11B10, but in the project where it was failing, only works with the Color Buffer set on R16G16B16A16. So what might be going on there?