mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[unity] Optimization: Not rendering slot alpha 0 attachments by default.
This commit is contained in:
parent
807f0586f1
commit
5fe6da05d6
@ -35,6 +35,12 @@
|
|||||||
#define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame.
|
#define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame.
|
||||||
//#define SPINE_DEBUG
|
//#define SPINE_DEBUG
|
||||||
|
|
||||||
|
// New optimization option to avoid rendering fully transparent attachments at slot alpha 0.
|
||||||
|
// Comment out this line to revert to previous behaviour.
|
||||||
|
// You may only need this option disabled when utilizing a custom shader which
|
||||||
|
// uses vertex color alpha for purposes other than transparency.
|
||||||
|
#define SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -196,7 +202,11 @@ namespace Spine.Unity {
|
|||||||
Slot[] drawOrderItems = drawOrder.Items;
|
Slot[] drawOrderItems = drawOrder.Items;
|
||||||
for (int i = 0; i < drawOrderCount; i++) {
|
for (int i = 0; i < drawOrderCount; i++) {
|
||||||
Slot slot = drawOrderItems[i];
|
Slot slot = drawOrderItems[i];
|
||||||
if (!slot.Bone.Active) {
|
if (!slot.Bone.Active
|
||||||
|
#if SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|| slot.A == 0f
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
workingAttachmentsItems[i] = null;
|
workingAttachmentsItems[i] = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -267,7 +277,11 @@ namespace Spine.Unity {
|
|||||||
Material lastRendererMaterial = null;
|
Material lastRendererMaterial = null;
|
||||||
for (int i = 0; i < drawOrderCount; i++) {
|
for (int i = 0; i < drawOrderCount; i++) {
|
||||||
Slot slot = drawOrderItems[i];
|
Slot slot = drawOrderItems[i];
|
||||||
if (!slot.Bone.Active) continue;
|
if (!slot.Bone.Active
|
||||||
|
#if SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|| slot.A == 0f
|
||||||
|
#endif
|
||||||
|
) continue;
|
||||||
Attachment attachment = slot.Attachment;
|
Attachment attachment = slot.Attachment;
|
||||||
IHasTextureRegion rendererAttachment = attachment as IHasTextureRegion;
|
IHasTextureRegion rendererAttachment = attachment as IHasTextureRegion;
|
||||||
if (rendererAttachment != null) {
|
if (rendererAttachment != null) {
|
||||||
@ -320,7 +334,11 @@ namespace Spine.Unity {
|
|||||||
Slot[] drawOrderItems = drawOrder.Items;
|
Slot[] drawOrderItems = drawOrder.Items;
|
||||||
for (int i = 0; i < drawOrderCount; i++) {
|
for (int i = 0; i < drawOrderCount; i++) {
|
||||||
Slot slot = drawOrderItems[i];
|
Slot slot = drawOrderItems[i];
|
||||||
if (!slot.Bone.Active) {
|
if (!slot.Bone.Active
|
||||||
|
#if SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|| slot.A == 0f
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
workingAttachmentsItems[i] = null;
|
workingAttachmentsItems[i] = null;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -789,7 +807,11 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
|
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
|
||||||
Slot slot = drawOrderItems[slotIndex];
|
Slot slot = drawOrderItems[slotIndex];
|
||||||
if (!slot.Bone.Active) continue;
|
if (!slot.Bone.Active
|
||||||
|
#if SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|| slot.A == 0f
|
||||||
|
#endif
|
||||||
|
) continue;
|
||||||
Attachment attachment = slot.Attachment;
|
Attachment attachment = slot.Attachment;
|
||||||
|
|
||||||
rg.x = slot.R2; //r
|
rg.x = slot.R2; //r
|
||||||
@ -832,7 +854,11 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
|
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
|
||||||
Slot slot = drawOrderItems[slotIndex];
|
Slot slot = drawOrderItems[slotIndex];
|
||||||
if (!slot.Bone.Active) continue;
|
if (!slot.Bone.Active
|
||||||
|
#if SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|| slot.A == 0f
|
||||||
|
#endif
|
||||||
|
) continue;
|
||||||
Attachment attachment = slot.Attachment;
|
Attachment attachment = slot.Attachment;
|
||||||
float z = slotIndex * settings.zSpacing;
|
float z = slotIndex * settings.zSpacing;
|
||||||
|
|
||||||
@ -988,7 +1014,11 @@ namespace Spine.Unity {
|
|||||||
Slot[] drawOrderItems = skeleton.DrawOrder.Items;
|
Slot[] drawOrderItems = skeleton.DrawOrder.Items;
|
||||||
for (int slotIndex = submeshInstruction.startSlot, endSlot = submeshInstruction.endSlot; slotIndex < endSlot; slotIndex++) {
|
for (int slotIndex = submeshInstruction.startSlot, endSlot = submeshInstruction.endSlot; slotIndex < endSlot; slotIndex++) {
|
||||||
Slot slot = drawOrderItems[slotIndex];
|
Slot slot = drawOrderItems[slotIndex];
|
||||||
if (!slot.Bone.Active) continue;
|
if (!slot.Bone.Active
|
||||||
|
#if SLOT_ALPHA_DISABLES_ATTACHMENT
|
||||||
|
|| slot.A == 0f
|
||||||
|
#endif
|
||||||
|
) continue;
|
||||||
|
|
||||||
Attachment attachment = drawOrderItems[slotIndex].Attachment;
|
Attachment attachment = drawOrderItems[slotIndex].Attachment;
|
||||||
if (attachment is RegionAttachment) {
|
if (attachment is RegionAttachment) {
|
||||||
|
|||||||
@ -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.",
|
"description": "This plugin provides the spine-unity runtime core.",
|
||||||
"version": "4.2.34",
|
"version": "4.2.35",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.timeline",
|
"name": "com.esotericsoftware.spine.timeline",
|
||||||
"displayName": "Spine Timeline Extensions",
|
"displayName": "Spine Timeline Extensions",
|
||||||
"description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime (via the spine-unity unitypackage), version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
"description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime (via the spine-unity unitypackage), version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
||||||
"version": "4.2.14",
|
"version": "4.2.15",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user