|
@@ -96,8 +96,9 @@ namespace Spine.Unity {
|
|
|
|
|
|
#if PER_MATERIAL_PROPERTY_BLOCKS
|
|
#if PER_MATERIAL_PROPERTY_BLOCKS
|
|
/// <summary> Applies only when 3+ submeshes are used (2+ materials with alternating order, e.g. "A B A").
|
|
/// <summary> 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.
|
|
/// You can disable this parameter when everything is drawn correctly to save the additional performance cost.
|
|
/// </summary>
|
|
/// </summary>
|
|
public bool fixDrawOrder = false;
|
|
public bool fixDrawOrder = false;
|
|
@@ -450,7 +451,7 @@ namespace Spine.Unity {
|
|
|
|
|
|
#if PER_MATERIAL_PROPERTY_BLOCKS
|
|
#if PER_MATERIAL_PROPERTY_BLOCKS
|
|
if (fixDrawOrder && meshRenderer.sharedMaterials.Length > 2) {
|
|
if (fixDrawOrder && meshRenderer.sharedMaterials.Length > 2) {
|
|
- SetDrawOrderMaterialPropertyBlocks();
|
|
|
|
|
|
+ SetMaterialSettingsToFixDrawOrder();
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
}
|
|
}
|
|
@@ -627,9 +628,9 @@ namespace Spine.Unity {
|
|
/// Otherwise, e.g. when using Lightweight Render Pipeline, deliberately separated draw calls
|
|
/// 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.
|
|
/// "A1 B A2" are reordered to "A1A2 B", regardless of batching-related project settings.
|
|
/// </summary>
|
|
/// </summary>
|
|
- private void SetDrawOrderMaterialPropertyBlocks() {
|
|
|
|
|
|
+ private void SetMaterialSettingsToFixDrawOrder() {
|
|
if (reusedPropertyBlock == null) reusedPropertyBlock = new MaterialPropertyBlock();
|
|
if (reusedPropertyBlock == null) reusedPropertyBlock = new MaterialPropertyBlock();
|
|
-
|
|
|
|
|
|
+
|
|
bool hasPerRendererBlock = meshRenderer.HasPropertyBlock();
|
|
bool hasPerRendererBlock = meshRenderer.HasPropertyBlock();
|
|
if (hasPerRendererBlock) {
|
|
if (hasPerRendererBlock) {
|
|
meshRenderer.GetPropertyBlock(reusedPropertyBlock);
|
|
meshRenderer.GetPropertyBlock(reusedPropertyBlock);
|
|
@@ -641,6 +642,8 @@ namespace Spine.Unity {
|
|
// material instances (not in terms of memory cost or leakage).
|
|
// material instances (not in terms of memory cost or leakage).
|
|
reusedPropertyBlock.SetFloat(SUBMESH_DUMMY_PARAM_ID, i);
|
|
reusedPropertyBlock.SetFloat(SUBMESH_DUMMY_PARAM_ID, i);
|
|
meshRenderer.SetPropertyBlock(reusedPropertyBlock, i);
|
|
meshRenderer.SetPropertyBlock(reusedPropertyBlock, i);
|
|
|
|
+
|
|
|
|
+ meshRenderer.sharedMaterials[i].enableInstancing = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|