Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I spent 3 hours trying to get GPU instancing to work for a custom sprite renderer shader with a material property block, only to figure out it’s a known bug that Unity decided not to fix and not to warn about. I mean they could at least have printed some warning in the console that setting a material property block on a sprite renderer will break instancing.

Anyways, once I found out it was their bug, I spent 15 minutes switching over to the mesh renderer and instancing is now working smoothly.

So I still get four draw calls, but at least most sprites with the same shape are now drawn in the same draw call. That’s happening because currently, each of the primitives have their own material. I guess maybe it would make sense to make them all use the same shader and just branch based on an enum value (instead of using #ifdefs like I do now). Anyways, I’m probably going to postpone that until I encounter performance issues to avoid doing too much premature optimization.