- Home /
Huge performance drop after using sprite Masks
Hi, I am working on a tiled based game and to achieve this visual I had to use sprite masks. 1 mask per tile. My problem is that as soon as I use the masks my fps drops from 150 (1000+ in build) to 3-4. Turning off the masks results in high fps again.
I have around 600 drawcalls.
Any one met with anything similar? What could be the problem?
as far as I know, Sprite $$anonymous$$asks break batching, so ins$$anonymous$$d of all the (I guess atlased) sprites being drawn with one drawcall, each one is drawn separately in conjunction with it's corresponding mask. that's probably quite a lot.
you be sure you can view the frame debugger found under Window menu.
Thank you for your answer. You are right. I get 200 draw calls for 1 layer of tiles. Without the masks I get 1. What could be the workaround here? Is it possible to combine the mask sprites and apply 1 larger mask? Would that help?
habe a look at tilemaps. might be a pain to set all adherent combinations up, but once done you can expect the same visual result with one drawcall.
Answer by Alliballibaba · Mar 30, 2019 at 10:05 AM
Don't know if this is still relevant, but i had the same problem when using many Sprtie Masks. Objects behind Sprite masks are rendered multiple times, which can result in a lot of draw calls. I recommend not using them at all, if you have many individual ones.
Answer by oroora6_unity · Mar 30, 2019 at 08:53 AM
The problem is that every mask creates at least 2 draw calls, this means that each sprite mask will slow down your rendering by a lot. The solution for this is to not use sprite masks. Instead write your own cutout shader and use a single object.