Great question! To create a shadow effect where the shadow from part B only appears on top of part A and blends naturally, here are the approaches you can use in Spine:
Using Multiply Blending
The most natural way to simulate a shadow is to use the Multiply blending mode on the slot containing your shadow attachment. This corresponds to the Multiply blending mode in Photoshop. A dark or semi-transparent image with Multiply blending will darken the pixels beneath it, which looks very natural for shadows.
In Spine, you can set this per slot under the slot's Blending property. The Photoshop import script will even automatically set this if your PSD layer uses the Multiply blending mode.
Tip for the shadow texture itself
Rather than using a black or dark shadow image, consider using a white base texture in the shape of your shadow, and then set the slot's color tint to a dark color such as:
- Pure black:
RGB (0, 0, 0)
- A slightly bluish dark gray for a more natural look:
RGB (0.1, 0.1, 0.2)
A white base texture gives you much more flexibility for tinting and recoloring later.
Controlling draw order for masking
To ensure the shadow only appears on top of part A and not elsewhere, you can control the draw order of your slots carefully — place the shadow slot above part A but manage its boundaries using the attachment image's transparent pixels. The shadow will naturally only be visible where the image has opaque pixels, and using Multiply blending means it will only visually affect what's drawn beneath it.
Using Clipping attachments
If you need the shadow to be strictly clipped to the boundary of part A, Spine's Clipping attachment is the right tool. You can define a clipping region that matches the shape of part A, and any slots within that clipping region will be masked to only appear inside it. This way, even if the shadow image extends beyond part A, it will be invisible outside the clipped area.
Combining a Clipping attachment shaped to part A with a shadow slot using Multiply blending is likely the most robust solution for your use case.