Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question URP Camera Solid Background Transparent

Discussion in 'Universal Render Pipeline' started by robert-1607, Apr 26, 2022.

  1. robert-1607

    robert-1607

    Joined:
    May 2, 2020
    Posts:
    8
    Hi everyone,

    I’m having some trouble in URP and can’t find any infos on this anywhere….

    how do I get to render then solid background of my camera as transparent?
    (Using the Built In Renderer it’s as simple as Camera > Background > Solid Background > Black with Alpha to 0.
    However in URP that doesn’t seem to work anymore.

    I’m creating a little overlay for a live stream. So I need the background to be transparent and just the foreground objects to be visible.
    I plan to capture the application using OBS. OBS allows transparency and it works flawlessly with the BuiltIn Renderer. I prefer using URP though.

    (I know I could work with a solid Green background and use it as a greenscreen to cutout my foreground objects. That causes a lot of fringing and a very unclean look. Also since transparency works in BuiltIn I figured there must be a way to achieve this in URP.)

    I’m very grateful for any kind of input on this topic!

    Many thanks in advance you all!

    (I made a previous post on the topic but I think my explanation of the issue probably wasn’t quite clear: https://forum.unity.com/threads/urp-camera-doesnt-allow-transparency-obs-overlay.1268867/)
     
  2. crazymmogamer

    crazymmogamer

    Joined:
    Mar 15, 2020
    Posts:
    4
    Did You found solution already?
     
  3. unityplease

    unityplease

    Joined:
    Aug 31, 2014
    Posts:
    32
    Any updates on this would be useful.
     
  4. unity_483C4357D3269025FA3B

    unity_483C4357D3269025FA3B

    Joined:
    Jul 2, 2022
    Posts:
    20
  5. robert-1607

    robert-1607

    Joined:
    May 2, 2020
    Posts:
    8
    Sadly no! If you find anything let me know, please.
     
  6. benjmitch

    benjmitch

    Joined:
    Nov 27, 2019
    Posts:
    17
    I am using URP to render a base camera into a render texture, and it was not coming out transparent despite me setting the camera to initialize to Solid Color with a transparent colour selected. Seemed like the same problem as here.

    Inspired by https://gamedev.stackexchange.com/a/181634 I tried changing the render texture format to a 32-bit format (specifically, R32G32B32A32_UINT). Et, voila.

    EDIT: After making a bit more progress, it's apparent that using that A32_UINT format, whilst it supports transparency, doesn't play nice with alpha blending in my shaders. Possibly [0-1] alpha float is being mapped into [0-1] in the UINT and so it is being catastrophically rounded - see docs at https://docs.unity3d.com/ScriptReference/Experimental.Rendering.GraphicsFormat.html. Instead, I've switched to R16G16B16A16_SFLOAT, and now everything is behaving as expected. I imagine there's some optimisation process here, but this format works and offers transparency and alpha blending.

    Headline: render texture format really matters, who knew :O?
     
    Last edited: Jan 17, 2023
  7. helios

    helios

    Joined:
    Oct 5, 2009
    Posts:
    308
    I’m doing this exact thing, and still cannot get the RenderTexture to be transparent. It is ignoring any alpha on the background color. Even disregarding the RenderTexture, the Camera background is ignoring any alpha in the color. Is there something else I’m missing here? Thanks!
     
    Last edited: Feb 13, 2023