Unity Community |

Hmm...I think I understand why I'm getting the lower draw calls when I piece together the scene in Maya. I have 4 layers in my environment, and they're all long strips that take up multiple screens. When I constructed the scene in ex2D, I created several sprite objects per layer and tiled them together to create my long strips. Each layer had about 5 or 6 sprite objects, so there were 20+ sprite objects in total.Hi bdjones, I did some test with "Unlit/Transparent" shader but it doesn't give me batched result, even without ex2D sprites.
Could you confirm that you are using "Unlit/Transparent" shader not "Unlit/Transparent Cutout"? Since the first one uses Alpha Blend and the second one uses Alpha Testing to determine the render order.
I think any shader using Alpha Blend will cause batching fail if you sandwich the material with another one. This is how Unity handles the render. If you don't want to change the sprite Z position to prevent the "sandwiching", you can use any shader with "Cutout" to get the batch going again. But it may cause performance issue on mobile devices.
In Maya, however, each layer is a single plane with subdivided sections. Then I UV mapped each subdivision to the same area on my texture atlases. When I imported the whole scene into Unity, I only had 4 game objects to deal with. I am using the Unlit/Transparent for my 4 texture atlases (not the Transparent Cutout...it doesn't deal with transparent edges well). But it seems the significant difference between these two approaches is the number of objects in the scene.
I'm guessing there's not a way within ex2D to "combine" sprite objects?
I hope that all made sense :-\
Hi bdjones, Sorry about second guessing your word ;p
ex2D doesn't "combine" sprite objects like maya exporting staticmesh. ex2D only combine texture so many sprite objects can use the same material. That's the requirement for Unity to do its dynamic batching job. If the objects share the same material can't be batched, then usually it's because there're object with another material gets in between.
Let's get this part straight out. I made a quick screenshot to mimic the ideal situation:
![]()
In this picture I have 3 layers of objects. Each layer has its own material. In an ideal world to make the batching work, you have to make sure the objects in different layers are all within their respective Z position range. It's ok to have objects on top of each other in a layer, just don't let object in another layer get in between.
If I go nuts and mix up the layers like this:
Then I get 6 drawcalls, since Unity can't batch two object if there's another object with another material in between.
Could you check your scene from other angle and see if there're layers mix up with each other? Thanks!
All right, I tweaked my atlases a bit. Now each layer has its own atlas (before everything was mixed across all the atlases). There are 5 atlases in total (the layer at the very back is composed of 2 atlases).
Here's what my scene looks like and the number of draw calls I'm getting on average:
http://twitpic.com/6pg7rc
Shouldn't I only be seeing 5 draw calls now instead of 9?
Edit: Sorry, I should explain what you're seeing. The layer at the far back is composed of 4 sprite objects and 2 atlases. The two middle layers have 3 sprite objects and 1 atlas each. The foreground is made up of 4 sprite objects and 1 atlas.
Hi bdjones,All right, I tweaked my atlases a bit. Now each layer has its own atlas (before everything was mixed across all the atlases). There are 5 atlases in total (the layer at the very back is composed of 2 atlases).
Here's what my scene looks like and the number of draw calls I'm getting on average:
http://twitpic.com/6pg7rc
Shouldn't I only be seeing 5 draw calls now instead of 9?
Edit: Sorry, I should explain what you're seeing. The layer at the far back is composed of 4 sprite objects and 2 atlases. The two middle layers have 3 sprite objects and 1 atlas each. The foreground is made up of 4 sprite objects and 1 atlas.
Hints
1. All sprite object must not keep Transform.Scale = (1,1,1). DO NOT touch it. Use exSprite.Scale instead. Because if Transform.Scale is not equal to 1,1,1. Unity will not add the object to batch
2. Camera NearClipPlane must larger than 100. I still seek the reason, but I just found this two days ago
--------------------------------------
Would you mind to send me this package so that I can test it in my PC. My E-Mail: KarasAya@gmail.com .
The draw call in unity is not just affect by material, but also depends on how much sprites you are rendering. So even if your objects are in 1 atlas, when you create lots of them, they still need to break up into several small batches. Anyway, I hope I can test this in my PC so see your feedback
BTW: I'm going to do a static batch feature if the all background object u create will not moved in the game.
Last edited by jwu; 09-23-2011 at 06:44 PM.
Hi jwu,Hi bdjones,
Hints
1. All sprite object must not keep Transform.Scale = (1,1,1). DO NOT touch it. Use exSprite.Scale instead. Because if Transform.Scale is not equal to 1,1,1. Unity will not add the object to batch
2. Camera NearClipPlane must larger than 100. I still seek the reason, but I just found this two days ago
--------------------------------------
Would you mind to send me this package so that I can test it in my PC. My E-Mail: KarasAya@gmail.com .
The draw call in unity is not just affect by material, but also depends on how much sprites you are rendering. So even if your objects are in 1 atlas, when you create lots of them, they still need to break up into several small batches. Anyway, I hope I can test this in my PC so see your feedback
BTW: I'm going to do a static batch feature if the all background object u create will not moved in the game.
I just sent you an email with my project file. Thanks for looking into this!
hello jwu
Is it safe to overwrite new ex2d to old project developed by old one?
And I have questions.
does it make mixing animation like megamn's charging?
ex)
Animation A
A1, A2, A3, A4 ....
Animation B
B1, B2, B3, B4 ...
Animation C
C1, C2, C3, C4 ....
result I hope
A1, B2, C3, A4 ....
And can the ex2d create blink animation?
Hello shinriyo,
The install and upgrade ex2D can be found in this documentation: http://www.ex-dev.com/ex2d/wiki/doku...manual:install, if something need to change when upgrading, we will point out in this page. So far, it is safe to upgrade if you start from v1.1.1.
I hope I can understand the question
. How can u generate a result A1,B2,C3,A4 when u have three different animation ? How they play together ? Can you explain it more clear may be better if u have pictures for this. Thanks in advance.
The blink animation can be done by using animation helper. and use Animation Clip working with it. The "08 - demo_sprite_animation_helper.unity" scene shows how to doing blink by Unity's Animation Clip and Use Animation Helper ON in inspector.And can the ex2d create blink animation?
Do you mean you want to have 3 different sets of running animation and each has a different outfit color? Then you want mix them up in a single running animation when your hero is charging up or has power up?hello jwu
Is it safe to overwrite new ex2d to old project developed by old one?
And I have questions.
does it make mixing animation like megamn's charging?
ex)
Animation A
A1, A2, A3, A4 ....
Animation B
B1, B2, B3, B4 ...
Animation C
C1, C2, C3, C4 ....
result I hope
A1, B2, C3, A4 ....
And can the ex2d create blink animation?
I think you can try the mixing with Play(string_name, int_index) and GetCurFrameInfo ().
Also you can try to switch the material for your character to have different effect blinking, but it will mess up your dynamic batching and cause performance issue.
How's the GUI component of this going?
Very nice! Whats the ETA? :P
Hi duke,
The v1.2.0 will be coming out this week.
What nantas shows, is a basic GUI rendering tool, it can draw scale9grid sprite use the texture from ex2D atlas. It can place and resize these sprites in the scene easily. It provides user a good way to form their GUI system.
We do have a plan in developing a full GUI framework which including animation, event handling and provides different GUI control directly for user. But we heart that Unity v3.5 have a new GUI framework. And we would like to see if the new GUI framework fulfill the demands. So we are hang on the GUI developing until v3.5 released. After that we will discuss if continue developing our own GUI add-on.
The atlassing in ex2D is fantastic.
I'd like to use it to atlas my textures with a similar workflow:
drop the texture in the material and if it belongs to an atlas, point to the atlas instead and change the uv range for you.
Do you have that ?
Hi,
Do you mean you want this texture tracking behavior to work for Unity mesh renderer component?
JWU, can you tell us about your ex2D tilemapping? Will it also be in your 1.2 release?!
Hi AirCooled,
The TileMapping will be an Add-On of ex2D, and it is still not stable enough for us to sell it. So it will not included in 1.2 release. We aim to release a free beta version in the middle of October.
The white around transparent texture, you can get rid of it by saving as PNG instead.Hi bdjones, Sorry about second guessing your word ;p
ex2D doesn't "combine" sprite objects like maya exporting staticmesh. ex2D only combine texture so many sprite objects can use the same material. That's the requirement for Unity to do its dynamic batching job. If the objects share the same material can't be batched, then usually it's because there're object with another material gets in between.
I am sure it is not trivial but so so so powerful.
If the complexity comes from the UI (how to display the material), the simplest way is no UI : the code looks up materials, find the textures, looks them up in the atlases and then does the same replacement + UV coordinate work as your script but on generic shaders.
In fact I think all your code can be generalized and the mesh generation separated. For instance today I wanted to do a manga mouth and I UV mapped the head to hold that texture, same for the eyes. Then I realized what a pain it will be to animate. If your scripts could be used for that purpose, imagine the power (pawa).