Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feature Request Allow to set RenderStateBlock globally

Discussion in 'General Graphics' started by Saniell, Nov 6, 2023.

  1. Saniell

    Saniell

    Joined:
    Oct 24, 2015
    Posts:
    183
    I'm trying to implement custom SRP, specifically shadows. To avoid artifacts for objects behind camera near plane I just set ZClip off in shader, which will not work very well for spot lights. I didn't want to add this logic to vertex shader so I thought just changing this parameter globally but doesn't seem to be really possible?

    Globally changing render state only works for DrawRenderers which is not only really useful for shadows, seems needlessly limited. I guess you could use DrawRenderers instead of DrawShadows, manually setting matricies and what not as a workaround, but I'd rather not.

    I'd like to suggest maybe adding ScriptableRenderContext.PushRenderState/PopRenderState? Or same for command buffer really.
    This could have more use cases like enabling conservative raster for certain objects (e.g. lines)
     
    ekakiya likes this.
  2. bijutoha

    bijutoha

    Joined:
    Sep 30, 2014
    Posts:
    4
    Your suggestion to add ScriptableRenderContext.PushRenderState/PopRenderState is a good one. It would allow for more control over the render state, which would be useful for cases like shadows and conservative raster.