I applied the multiply blending mode to an asset in my animation however when exporting and implementing in Unity the asset shows as if no blending mode was applied! help please!
Multiply Blending not exporting as it should
- Edited
Ah!
It's actually exported. But the Spine-Unity runtime doesn't support automatically applying multiply blend mode via slot properties.
Like most of the other runtimes, Spine-Unity applies the Additive mode "for free" by exploiting a property of Premultiply alpha blending, and pushing the needed data to vertex colors.
The same can't be done for Multiply.
So it needs to be done by creating a separate material for your multiply parts, then using code like this:
using UnityEngine;
namespace Spine.Unity.Examples {
public class ApplyMultiplyMaterial : MonoBehaviour {
public Material multiplyVersionOfMaterial;
void Start () {
if (multiplyVersionOfMaterial == null) return;
var skeletonRenderer = GetComponent<SkeletonRenderer>();
if (skeletonRenderer == null) return;
var slotMaterials = skeletonRenderer.CustomSlotMaterials;
foreach (var s in skeletonRenderer.Skeleton.Slots)
if (s.Data.BlendMode == BlendMode.multiply)
slotMaterials[s] = multiplyVersionOfMaterial; // add the multiply Slot s into the CustomSlotMaterials dictionary.
}
}
}
You can use this shader for your Material if you are using the default premultiply alpha settings: https://gist.github.com/pharan/d24ed2109018c6139d1b883bbf793c66
If you are using straight alpha, you can use any straight alpha multiply shader. Like the Particle/Multiply.
If you really just needed to apply the multiply blend mode to the whole thing instead of per slot, you can just replace the shader on your skeleton's main materials. No extra script needed.
Thanks so much Pharan, I know nothing about this but I'll let the dev take a look!
Pharan wroteThe same can't be done for Multiply.
So it needs to be done by creating a separate material for your multiply parts, then using code like this:
Is this done in Spine? if so how do I hand pick the slots to create a new atlas?
This is all Unity.
Pharan wroteThis is all Unity.
Dear Pharan, I checked with my dev this is their reply
"RE: We can't do that since all parts are in one image. 1 image = 1 material, 2 images = 2 materials. You'll have to put the parts that should have blend mode in one image and we can create a separate material for it"
How can they or I make two PNG atlases or how would they pick one portion of the PNG Atlas to apply the blend mode? sorry to keep asking about this, I guess we need a more thorough explanation.
Tell your developer:
1) Download and import this unitypackage:
http://esotericsoftware.com/files/runtimes/unity/spine-unity-SlotBlendModes_3_5.unitypackage
2) Right-click on SkeletonAnimation, and choose "Add Slot Blend Modes Component"
The blend modes will only be visible in Play Mode.
This module will be included in the 3.6 runtime.