Search Unity

How to use ScriptableRenderContext.DrawRenderers() on a subset of renderers?

Discussion in 'Universal Render Pipeline' started by nick_unity869, Jan 14, 2022.

  1. nick_unity869

    nick_unity869

    Joined:
    Nov 30, 2021
    Posts:
    3
    I have custom render pass draws my renderers in 2 calls, in the first call a depth buffer is generated which informs what renderers should be drawn in the second call. When i saw that `FilteringSettings` contains a `renderingLayerMask` I thought I had my solution. I could use 1 flag for call 1 and another for call 2. What I have found out is that it seems like the `renderingLayerMask` on the `MeshRenderer` is locked in after the first call to `DrawRenderers`. For example, if I change the `rendereringLayerMask` and do another call to `DrawRenderers` I do not see the renderer's I expect rendered to the screen.

    Is this a bug with `renderingLayerMask`? Is there a better solution for more fine grained control of which renderers are drawn when? The next best solution I could find was to use `CommandBuffer.DrawMesh` but then I have to do all the lighting setup on my own.