Hello Starling community!
My first Starling game contains lots of game objects which are distinguished mostly by color. Main objects have their assets drawn individually,
but auxiliary assets like explosions, blasts, glows are each in one color, and I use ColorMatrixFilters to change their colors.
The artwork is such that I cannot just use color property on them. I also use ColorMatrixFilters to indicate various events and states of main objects.
For example, some main object (MovieClip) is ready to explode. Then ColorMatrixFilter with tweened brightness and contrast is applied to the object to make it blink,
then before exploding brightness is tweened to maximum, then I add explosion MovieClip and use ColorMatrixFilter to colorize this explosion to match destroyed object's color.
Because there can be more than 100 of main objects on stage, the number of draw calls during crux moments jumps by dozens, despite all game art being in same atlas, and hurts performance.
So far I've came up with few ideas on how to improve performance:
1) Separate all explosions and auxiliary assets that require colorization into separate atlas. Colorize them manually and compress all colors into one (or many) atf textures -
this will slow initial game startup. Or colorize them during runtime and then render them in colors into RenderTexture. This will take less time to load, but consume more runtime GPU memory.
Then draw assets from this atlas into separate layers. This should increase performance, but I still have to apply ColorMatrixFilters to apply brightens, contrast effects.
2) Create custom DisplayObject subclass for colorized assets, so I can batch-render them with different ColorMatrixFilters in one draw call. I don't know if this even possible.
But maybe I should look at Batch Renderer Starling Extension?
3) Use heavy sorting and apply ColorMatrixFilters to groups of objects. This will require at worst 1 + (number of colors) * (number of colorized object types) draw calls, which is still a lot.
Any advice on how to deal with such problem?