2D Toolkit Forum

2D Toolkit => Support => Topic started by: pan_henryk on May 16, 2014, 12:38:57 pm

Title: Optimal way for creating multiple sprites respecting z-order
Post by: pan_henryk on May 16, 2014, 12:38:57 pm
Hi,

Some time ago I used static sprite batcher to optimize creation and drawing of multiple static sprites which previously had separate game objects.
Now I am looking to do it with another group of sprites, but my problem is z-order, which rules out static sprite batcher:

- we are using z-order not layers to determine drawing order
- static sprite objects drawing order can be mixed with dynamic ones (which need separate game objects).

Any tips how this could be done with 2dtoolkit? My goal is to get rid of myriad of game objects, reducing draw calls is not important here.
Each of my sprites would have scale rotation and position and possibly a collider.
Maybe sprite batcher could be hacked to do it? (separate renderers?)

Thanks in advance,
Title: Re: Optimal way for creating multiple sprites respecting z-order
Post by: unikronsoftware on May 17, 2014, 09:07:25 pm
The static sprite batcher could be hacked for this I suppose, or you could manually split up into foreground and background static batchers. If you dont need alpha blending on the static sprites, you could use alpha test and get some nice gains there? That way you could just zsort with those.
Title: Re: Optimal way for creating multiple sprites respecting z-order
Post by: pan_henryk on May 19, 2014, 09:03:09 am
I tried splitting batchers - that is starting new one after each time dynamic object appears in z order. Seems very promising when tested on PC, now I need to verify performance on mobile device.