diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs index 3789624b4..a5539fa7e 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Components/SkeletonRendererInspector.cs @@ -120,7 +120,7 @@ namespace Spine.Unity.Editor { TangentsLabel = new GUIContent("Solve Tangents", "Calculates the tangents per frame. Use this if you are using lit shaders (usually with normal maps) that require vertex tangents."); TintBlackLabel = new GUIContent("Tint Black (!)", "Adds black tint vertex data to the mesh as UV2 and UV3. Black tinting requires that the shader interpret UV2 and UV3 as black tint colors for this effect to work. You may also use the default [Spine/Skeleton Tint Black] shader.\n\nIf you only need to tint the whole skeleton and not individual parts, the [Spine/Skeleton Tint] shader is recommended for better efficiency and changing/animating the _Black material property via MaterialPropertyBlock."); SingleSubmeshLabel = new GUIContent("Use Single Submesh", "Simplifies submesh generation by assuming you are only using one Material and need only one submesh. This is will disable multiple materials, render separation, and custom slot materials."); - FixDrawOrderLabel = new GUIContent("Fix Draw Order", "Applies only when 3+ submeshes are used (2+ materials with alternating order, e.g. \"A B A\"). If true, MaterialPropertyBlocks are assigned at each material to prevent aggressive batching of submeshes by e.g. the LWRP renderer, leading to incorrect draw order (e.g. \"A1 B A2\" changed to \"A1A2 B\"). You can disable this parameter when everything is drawn correctly to save the additional performance cost."); + FixDrawOrderLabel = new GUIContent("Fix Draw Order", "Applies only when 3+ submeshes are used (2+ materials with alternating order, e.g. \"A B A\"). If true, GPU instancing will be disabled at all materials and MaterialPropertyBlocks are assigned at each material to prevent aggressive batching of submeshes by e.g. the LWRP renderer, leading to incorrect draw order (e.g. \"A1 B A2\" changed to \"A1A2 B\"). You can disable this parameter when everything is drawn correctly to save the additional performance cost. Note: the GPU instancing setting will remain disabled at affected material assets after exiting play mode, you have to enable it manually if you accidentally enabled this parameter."); MaskInteractionLabel = new GUIContent("Mask Interaction", "SkeletonRenderer's interaction with a Sprite Mask."); MaskMaterialsHeadingLabel = new GUIContent("Mask Interaction Materials", "Materials used for different interaction with sprite masks."); MaskMaterialsNoneLabel = new GUIContent("Normal Materials", "Normal materials used when Mask Interaction is set to None."); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs index f176fc30d..c22582e8a 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonRenderer.cs @@ -96,8 +96,9 @@ namespace Spine.Unity { #if PER_MATERIAL_PROPERTY_BLOCKS /// Applies only when 3+ submeshes are used (2+ materials with alternating order, e.g. "A B A"). - /// If true, MaterialPropertyBlocks are assigned at each material to prevent aggressive batching of submeshes - /// by e.g. the LWRP renderer, leading to incorrect draw order (e.g. "A1 B A2" changed to "A1A2 B"). + /// If true, GPU instancing is disabled at all materials and MaterialPropertyBlocks are assigned at each + /// material to prevent aggressive batching of submeshes by e.g. the LWRP renderer, leading to incorrect + /// draw order (e.g. "A1 B A2" changed to "A1A2 B"). /// You can disable this parameter when everything is drawn correctly to save the additional performance cost. /// public bool fixDrawOrder = false; @@ -450,7 +451,7 @@ namespace Spine.Unity { #if PER_MATERIAL_PROPERTY_BLOCKS if (fixDrawOrder && meshRenderer.sharedMaterials.Length > 2) { - SetDrawOrderMaterialPropertyBlocks(); + SetMaterialSettingsToFixDrawOrder(); } #endif } @@ -627,9 +628,9 @@ namespace Spine.Unity { /// Otherwise, e.g. when using Lightweight Render Pipeline, deliberately separated draw calls /// "A1 B A2" are reordered to "A1A2 B", regardless of batching-related project settings. /// - private void SetDrawOrderMaterialPropertyBlocks() { + private void SetMaterialSettingsToFixDrawOrder() { if (reusedPropertyBlock == null) reusedPropertyBlock = new MaterialPropertyBlock(); - + bool hasPerRendererBlock = meshRenderer.HasPropertyBlock(); if (hasPerRendererBlock) { meshRenderer.GetPropertyBlock(reusedPropertyBlock); @@ -641,6 +642,8 @@ namespace Spine.Unity { // material instances (not in terms of memory cost or leakage). reusedPropertyBlock.SetFloat(SUBMESH_DUMMY_PARAM_ID, i); meshRenderer.SetPropertyBlock(reusedPropertyBlock, i); + + meshRenderer.sharedMaterials[i].enableInstancing = false; } } #endif