[unity] Fixed SkeletonGraphic Cull transparent mesh on additive submesh renderers. Closes #2994.

This commit is contained in:
Harald Csaszar 2025-12-10 18:39:56 +01:00
parent cb3da8ef95
commit 37ab2b8186
2 changed files with 16 additions and 5 deletions

View File

@ -1157,14 +1157,13 @@ namespace Spine.Unity {
BlendModeMaterials blendModeMaterials = skeletonDataAsset.blendModeMaterials; BlendModeMaterials blendModeMaterials = skeletonDataAsset.blendModeMaterials;
bool hasBlendModeMaterials = blendModeMaterials.RequiresBlendModeMaterials; bool hasBlendModeMaterials = blendModeMaterials.RequiresBlendModeMaterials;
bool hasMaterialOrTextureOverride = HasMaterialOrTextureOverride; bool hasMaterialOrTextureOverride = HasMaterialOrTextureOverride;
bool hasPMAAdditiveSlots = HasPMAAdditiveSlots(instructions);
MeshGenerator meshGenerator = meshGenerators.Items[0]; MeshGenerator meshGenerator = meshGenerators.Items[0];
bool pmaVertexColors = meshGenerator.settings.pmaVertexColors; bool pmaVertexColors = meshGenerator.settings.pmaVertexColors;
bool allowCullTransparentMesh = true;
#if HAS_CULL_TRANSPARENT_MESH #if HAS_CULL_TRANSPARENT_MESH
bool mainCullTransparentMesh = this.canvasRenderer.cullTransparentMesh; bool mainCullTransparentMesh = this.canvasRenderer.cullTransparentMesh;
#endif #endif
if (HasMaterialOrTextureOverride || hasBlendModeMaterials || hasPMAAdditiveSlots) {
if (HasMaterialOrTextureOverride || hasBlendModeMaterials) {
for (int i = 0, count = sharedMaterials.Length; i < count; ++i) { for (int i = 0, count = sharedMaterials.Length; i < count; ++i) {
Texture originalTexture = instructionItems[i].material.mainTexture; Texture originalTexture = instructionItems[i].material.mainTexture;
@ -1177,7 +1176,8 @@ namespace Spine.Unity {
customTextureOverride.TryGetValue(Texture2D.whiteTexture, out replacementTexture)) // white texture entry = replace-all customTextureOverride.TryGetValue(Texture2D.whiteTexture, out replacementTexture)) // white texture entry = replace-all
usedTextureItems[i] = replacementTexture; usedTextureItems[i] = replacementTexture;
} }
if (hasBlendModeMaterials) { if (hasBlendModeMaterials || hasPMAAdditiveSlots) {
bool allowCullTransparentMesh = true;
Material blendModeMaterial = GetBlendModeMaterial(instructionItems[i], blendModeMaterials, Material blendModeMaterial = GetBlendModeMaterial(instructionItems[i], blendModeMaterials,
pmaVertexColors, ref allowCullTransparentMesh); pmaVertexColors, ref allowCullTransparentMesh);
if (blendModeMaterial != null) if (blendModeMaterial != null)
@ -1198,6 +1198,17 @@ namespace Spine.Unity {
} }
} }
/// <returns>True if any element of the given <c>instructions</c> list has
/// <see cref="SubmeshInstruction.hasPMAAdditiveSlot"/> set, false otherwise.</returns>
protected bool HasPMAAdditiveSlots (ExposedList<SubmeshInstruction> instructions) {
SubmeshInstruction[] items = instructions.Items;
for (int i = 0, count = instructions.Count; i < count; ++i) {
if (items[i].hasPMAAdditiveSlot)
return true;
}
return false;
}
/// <returns>The respective blend mode material, or null if no blend mode material is required.</returns> /// <returns>The respective blend mode material, or null if no blend mode material is required.</returns>
protected Material GetBlendModeMaterial (SubmeshInstruction instruction, BlendModeMaterials blendModeMaterials, protected Material GetBlendModeMaterial (SubmeshInstruction instruction, BlendModeMaterials blendModeMaterials,
bool pmaVertexColors, ref bool allowCullTransparentMesh) { bool pmaVertexColors, ref bool allowCullTransparentMesh) {

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity", "name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime", "displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.", "description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.",
"version": "4.3.33", "version": "4.3.34",
"unity": "2018.3", "unity": "2018.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",