Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question UnityPerMaterial CBuffer inconsistent size inside a SubShader

Discussion in 'Graphics for ECS' started by noworknofood, Apr 12, 2023.

  1. noworknofood

    noworknofood

    Joined:
    Mar 22, 2023
    Posts:
    2
    A BatchDrawCommand is using a pass from the shader "Lpk/LightModel/ToonLightBase" that is not SRP Batcher compatible. Reason: "UnityPerMaterial CBuffer inconsistent size inside a SubShader" (ShadowCaster)
    This is not supported when rendering with a BatchRendererGroup (or Entities Graphics).


    Using Entities and Entities Graphic 1.0.0-pre.65. unity version : 2022.2.11f1c1 and there is also no issues when using play mode in the Editor.
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    352
    This error happens because the shader you are using is not compatible with the SRP Batcher. The most likely reason is that there are #ifdefs in the UnityPerMaterial constant buffer definition, which causes that constant buffer to be different for different variants of the shader, which is not supported when using the SRP Batcher. Entities Graphics relies on the SRP Batcher to render, so all shaders used with it must be SRP Batcher compatible.

    The reason why this only happens in the player and not the editor is that the editor compiles shader variants on demand, based on what is used, and the player build compiles all variants up front.

    The way to fix this problem is to fix the shader so it's SRP Batcher compatible. In these kinds of cases, it's usually not difficult and typically just removing the #ifdefs is enough.
     
  3. noworknofood

    noworknofood

    Joined:
    Mar 22, 2023
    Posts:
    2

    New
    sorry .I made a mistake .
    No matter which mode is used, there are issues