Mog

Hello

On one of our character we are using a clipping mask to hide him inside the ground.
I noticed a huge FPS drop when this anim is playing.

I'm looking for advises on how we can optimize this :


The build of this character is pretty heavy with a couples of bones and skins.



Thanks
Avatar
Mog
  • Postovi: 27

Mario

The performance of clipping depends on the number of vertices in the clipping mask and the number of triangles in your region and mesh attachments. You can find the stats for the latter in the metrics view: Metrics view - Spine User Guide

Please post them so we have a better idea about your model's setup.
Avatar
Mario

Mario
  • Postovi: 3033

Jamez0r

Like Mario said, clipping has to be calculated for all of the attachment images that are being clipped, and it looks like basically everything needs to be clipped on your character when they are in the ground (since the only visible part is the top of their head).

I believe clipping works by calculating new mesh vertices for each attachment, so it is done on the CPU and is expensive if a lot of attachment images (with lots of vertices) need to be clipped.

I would look into using a Sprite Mask (https://docs.unity3d.com/Manual/class-SpriteMask.html), to mask out the area that is considered 'below ground', and then use the "Mask Interaction" setting on the SkeletonAnimation component to make it 'Visible Outside Mask'.

When you use Masking/Stenciling, it's calculated on the GPU (it basically checks whether or not the individual pixel should be drawn to the screen or not, based on if that pixel location has had its mask/stencil value set) and is very efficient.
Avatar
Jamez0r
  • Postovi: 356

Mog

Hello And thanks a lot for you replay.

Indeed it seems that using mask in spine isn't a good solution in this case and I should look into using unity masking tool for this.

I'm posting the stats just for the record :

Avatar
Mog
  • Postovi: 27

Nate

There are some performance tips here:
Clipping attachments - Spine User Guide: Performance

The best case is making your clipping polygon have only 3 vertices (a triangle). You can make the triangle very large, it's size doesn't affect performance.

Next to get good performance you need to try to clip as few attachments having as few vertices as possible. Use region attachments (4 vertices) where possible. Hide attachments once they are fully clipped.

Doing all that may be a pain and if you still have lots of attachments, it may still not perform well. Doing the clipping other ways, as suggested above, may be easier.
Avatar
Nate

Nate
  • Postovi: 11855


Natrag na Unity