Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Question How to use new URP Rendering Layers?

Discussion in '2022.2 Beta' started by pHghost, Jul 15, 2022.

  1. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    The new features post for 2022.2 mentions URP Rendering Layers. Is this a new feature and if so, how do you access it?

    I have been using Render Objects (part of Universal Renderer Data, in the Renderer Features section) for a similar effect up till now, but that seems to now be broken as of 2022.2 and still listed as experimental.

    What is the correct approach to layer rendering now, then and how to set it up?
     
  2. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    Anyone from Unity Technologies have any input on this? @antonie_unity
     
  3. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    You can enable it in the Render Pipeline settings or Assets.

    It is then Inspector-configurable for Renderers (as in, Components) related to the Lighting Layers, for Lights, and on the Renderers (as in, "Renderer Asset", the things the Pipeline Assets and Cameras use).

    It is basically an additional 32-Layer system on top of Unity's standard layer system, but it's not competing with Physics layers and has no predefined layers like "TransparentFX" etc.

    PS: Wow I just realized how poor Unity's naming choice for the new SRP Renderers was. :D
     
  4. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    @Thygrrr Thanks, that helped me find the layers!

    Now the question of getting it to work. I can add/delete layers in the settings, but how do you get different GameObjects, layers to render on separate Render Layers? :confused:

    I looked through Project Settings, Inspector Camera and GameObject Settings, Layer Settings and couldn't find any way for cameras, layers or GameObjects to be assigned to a Render Layer.
     
    Last edited: Jul 30, 2022
    trombonaut likes this.
  5. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    I thought these are just lighting layers, so that you can receive/not receive lighting from lights assigned to that layer?
     
  6. pHghost

    pHghost

    Joined:
    Jan 7, 2018
    Posts:
    61
    I don't think so, @michalpiatek, that is not how they are described in the 2022.2 blog post, and if so, the name would be doubly confusing.

    Nonetheless, I checked Inspector Light Settings just to make sure and there's no way to assign lights to these layers either.

    Still a mystery how these are supposed to be put to use.
     
    reinfeldx likes this.
  7. JungHyun_

    JungHyun_

    Joined:
    Aug 31, 2021
    Posts:
    1
    @pHghost, did you find it out how to work?
     
    reinfeldx likes this.
  8. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    There's a discussion that might be relevant here, but we're similarly blocked and waiting for some answers from Unity.
     
  9. r9shackleford

    r9shackleford

    Joined:
    Jul 23, 2019
    Posts:
    23
    It's not exposed. Perhaps there's a reason Unity has not done it? I'm not sure.

    The DrawObjectsPass internally uses a FilteringSettings which accepts a renderingLayerMask. Here's a diff to implement it, you'll need to copy URP locally to your packages directory modify it and not have it overwritten.

    Here's a patch that adds it to the base renderer filter settings.
    https://gist.github.com/rsw0x/621ff39caa9fd002d954e475467b5ea8

    Similar changes can be done to expose it in the 'Render Objects' rendering feature. Here's a gist with a patch that adds it to both the base rendering filter options and the 'Render Objects' rendering feature.
    https://gist.github.com/rsw0x/0fbef12346c7a5e605605fb6c9bd9975


    Something I noticed is the editor for the layer seems to have issues with selecting all layers and resets it to 'None' instead, so you'll need to make an extra one and keep it deactivated.

    Our use-case for this is for rendering objects with a stacked camera in front of other objects while preserving their layers for physics purposes.
     
    Last edited: Oct 31, 2022
    Qriva likes this.
  10. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    There's new discussion and some comments from Unity in the linked thread above.