Closed rayxuln closed 4 years ago
The animation "portal" in SpineBoy is not the same as expected when played using this runtime module in Godot.
Tricky. Looking at the example, the SpineSprite is only visible when inside a clipping mesh. Godot is not really supporting clipping masks. I found two ways of doing this:
Lightmask using a texture Looking at the official demo, this would entail creating 2 lights: one for all visible items (outside of draworder and end slot) and one for the masked item. The second would need a texture assigned that is rendered from the clipping area. I have to look closer at how the certain lights mask certain nodes. However, these lights will interfere with other lights in the scene and create issues when normal maps are used.
Shader which would have to look at the mesh and set alpha according to the pixel position: As it turns out, the clipping is between its draworder and the end slot property. This means instead of attaching the shader to spinesprite, it would have to be attached to each slot node. Godot currently only supports a single shader per node. It would prevent using shaders on those nodes from doing other things. I can see an optional property implementation that allows for either outside shaders or clipping.
This would entail creating a mask texture from the clipping mesh, transforming it for each individual slot for rotation and translation and then feeding it into an attached masking shader. Ugh!
I don't really like either solution to the issue. Looking at the animation, I would leave it to the game developer to mask the actual sprite using what they want in that situation. The portal example can be fairly simply replicated by having the portal and spineboy as two different nodes and masking spineboy in the engine itself. I've done similar things with the spine node and it's fairly straightforward since you can use a baked texture for a shader on a parent node.
Actually scrap that. Looking at https://github.com/EsotericSoftware/spine-runtimes/blob/3.8/spine-cocos2dx/src/spine/SkeletonRenderer.cpp, clipping can be done by eliminating vertices from the attachments using the runtime SkeletonClipping class. Gotta dig deeper.
Nailed it.
Next is to test its stability.
Please explain.