Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug SRP Batcher and BatchRendererGroup incompatible?

Discussion in 'General Graphics' started by Arycama, Sep 9, 2020.

  1. Arycama

    Arycama

    Joined:
    May 25, 2014
    Posts:
    183
    I'm using a Nested Grid with BatchRendererGroup to draw an Ocean, as using Graphics.DrawMeshInstanced was causing all kinds of problems in regards to lighting, handling scene+game view, etc. (Also, being able to handle the culling is nice)

    I wrapped my Material Properties with cbuffer macros (UnityPerMaterial), and the shader would say it's SRP compatible. However my mesh would stop rendering entirely. Eg it doesn't even appear in the FrameDebugger.

    If I simply comment out the cbuffer-related lines, everything works again as normal.
    Is this a limitation of BatchRendererGroup?

    I can understand if using BatchRendererGroup and SRPBatcher together does not make sense in terms of improving performance, as a BatchRendererGroup would draw all the meshes using the same material anyway, without extra SetPass calls.

    However, making a Shader SRP-Batcher compatible should not stop it from rendering entirely when using BatchRendererGroup. Do I need to add some kind of tag to tell my shader to ignore SRP Batcher?

    This is mostly an issue because I want to use BatchRendererGroup to draw some other objects, which use a different SRP-Compatible shader, but the Shader will also be used for non-BatchRendererGroup rendering. So I don't want to have to make an SRP-Batcher and non SRP-Batcher version of each shader, just so I can use them interchangeably with BatchRenedererGroup and regular MeshRenderers.

    Thanks for any info.
     
    Klausology and inspoy_tap4fun like this.