• Runtimes
  • [Release] Ghost Renderer for Monogame / XNA

Related Discussions
...

Hey there all. I'm very new to Spine but love seeing all the cool things Spine brings to Animators and Games.
I saw this cool Ghost Effect in a Unity tutorial but unfortunately couldn't find a script for Monogame / XNA. So I wrote my own. Hope I helped anyone with it.

I am not a super programmer so if there's something that could be done to improve the script please do say.

Image removed due to the lack of support for HTTPS. | Show Anyway

Initialize as :

SpineGhostRenderer ghostRenderer;
ghostRenderer = new SpineGhostRenderer(skeletonData);

Drawing / Updating

public void Update(GameTime gameTime)
{
        float deltaTime = gt.ElapsedGameTime.Milliseconds / 1000f;
        ghostRenderer.Update(state, Position, deltaTime);
}

public void Draw()
{
        skeletonRenderer.Begin();
        //Render before the actual skeleton inside the batch.
        ghostRenderer.Draw(skeletonRenderer);
        skeletonRenderer.Draw(skeleton);
        skeletonRenderer.End();
}

Neat, post a screenshot for other folks to look at as well!

Interesting solution. Thanks for sharing!

The Spine-Unity version stores previously-rendered meshes, instead of having to rebuild meshes from a buffer of skeletons every frame.
It saves on a lot of calculations. Might be a useful alternative! 🙂

Hey Pharan, I did check out the Unity script but don't know how you'd translate this well to Monogame / XNA.
As my knowledge of Monogame and Spine isn't that great. Any suggestions on how to do it similar to the Unity Script ?

Could be wrong but would it be an idea of using a RenderTarget2D ?

Pharan wrote

Interesting solution. Thanks for sharing!

The Spine-Unity version stores previously-rendered meshes, instead of having to rebuild meshes from a buffer of skeletons every frame.
It saves on a lot of calculations. Might be a useful alternative! 🙂

5 days later

RenderTarget2D would store (and write to) a texture per ghost, which seems a bit heavy. Calculating the skeleton poses isn't a problem unless you see poor performance from posing the skeleton so many times. If you look at the spine-xna skeleton renderer, it configures items from the batcher. You can be more efficient by storing all the item configurations for a particular ghost. Also look at the batcher (it is very simple) and you'll see it reuses the items, so you can't hold on to items across frame renders, but you could copy them.

Nate wrote

RenderTarget2D would store (and write to) a texture per ghost, which seems a bit heavy. Calculating the skeleton poses isn't a problem unless you see poor performance from posing the skeleton so many times. If you look at the spine-xna skeleton renderer, it configures items from the batcher. You can be more efficient by storing all the item configurations for a particular ghost. Also look at the batcher (it is very simple) and you'll see it reuses the items, so you can't hold on to items across frame renders, but you could copy them.

Not quite sure what you mean by "storing all the item configurations" new to Spine and Monogame.

But if I understand correctly you're suggesting getting the "pose" of the skeleton every time a ghost is to render. And apply it to the ghostSkeleton ?

The renderer gets items from the batcher and configures them with some data. Save that data so you can later get items from the batcher and configure them again with that data to draw the same pose.