Search Unity

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:
    351
    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