{
  "id": "unity/rendering-batch-break-instantiation",
  "signature": "Warning: A different rendering setup is being used for rendering than the one used for instantiating. Batch break.",
  "signature_zh": "警告：用于渲染的渲染设置与用于实例化的设置不同。批次中断。",
  "regex": "A different rendering setup is being used for rendering than the one used for instantiating\\. Batch break\\.",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Material property blocks or shader keywords differ between instantiation and rendering of a GameObject, causing the GPU instancing batch to break.",
  "root_cause_type": "generic",
  "root_cause_zh": "GameObject 的实例化和渲染之间材质属性块或着色器关键字不同，导致 GPU 实例化批次中断。",
  "versions": [
    {
      "version": "Unity 2022.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2021.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Disabling GPU instancing globally reduces performance and doesn't address the root cause of property block mismatch.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Setting material.renderQueue manually often ignores the underlying shader property block differences.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using MaterialPropertyBlock.Clear() before every draw call may cause flickering and still not synchronize with instancing.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure all instanced objects use the same MaterialPropertyBlock values by assigning them in a single batch: `MaterialPropertyBlock block = new MaterialPropertyBlock(); renderer.GetPropertyBlock(block); block.SetColor(\"_Color\", Color.red); renderer.SetPropertyBlock(block);`",
      "success_rate": 0.8,
      "how": "Ensure all instanced objects use the same MaterialPropertyBlock values by assigning them in a single batch: `MaterialPropertyBlock block = new MaterialPropertyBlock(); renderer.GetPropertyBlock(block); block.SetColor(\"_Color\", Color.red); renderer.SetPropertyBlock(block);`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable per-instance shader keywords by removing `#pragma multi_compile` variants that vary per object, or use `Shader.EnableKeyword` globally.",
      "success_rate": 0.75,
      "how": "Disable per-instance shader keywords by removing `#pragma multi_compile` variants that vary per object, or use `Shader.EnableKeyword` globally.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `Graphics.DrawMeshInstanced` with a shared material and property block array instead of individual renderers.",
      "success_rate": 0.85,
      "how": "Use `Graphics.DrawMeshInstanced` with a shared material and property block array instead of individual renderers.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Ensure all instanced objects use the same MaterialPropertyBlock values by assigning them in a single batch: `MaterialPropertyBlock block = new MaterialPropertyBlock(); renderer.GetPropertyBlock(block); block.SetColor(\"_Color\", Color.red); renderer.SetPropertyBlock(block);`",
    "Disable per-instance shader keywords by removing `#pragma multi_compile` variants that vary per object, or use `Shader.EnableKeyword` globally.",
    "Use `Graphics.DrawMeshInstanced` with a shared material and property block array instead of individual renderers."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/Manual/GPUInstancing.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-08-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}