Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by shopguy · Apr 04, 2014 at 12:15 AM · 2dspritebatching

Sprite batching

Is it possible to get sprite batching to work regardless of what order your sprites are drawn in? From testing it seems that every time a different sprite is going to be drawn, it ends the current batch. So if I have 3 sprites, 10 each, and I set the "order in layer" at random, I get lots of draw calls and not much batching. If I set them so that all 10 sprites of each type are drawn together, I get 3 draw calls, perfect batching.

I understand batching might not be possible/practical if the sprites actually overlap, but in my case I have some that overlap and some that don't. While I could write my own logic to order things in an optimized way, I'm hoping that something already exists in Unity.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shopguy · Apr 04, 2014 at 03:15 AM 0
Share

I guess what I was hoping for is that Unity would at least batch sprites together if it noticed that they didn't overlap other sprites. For example, if it was "time" (z-index/layer) to draw a sprite, Unity might think "hey, I just drew a different type of sprite, before I draw this next one I'll go see if there are any others of the same type I can draw, so they'll batch together". I guess that might be difficult to do at the engine level. So I'll assume the answer is NO and accept ivomarel's answer because I think it will work for other future readers and is a good "general" answer, just not for my specific case.

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by ivomarel · Apr 04, 2014 at 12:40 AM

Yes, make sure that the sprites are in the same atlas. When you select a sprite, (Texture type should be sprite), look at the inspector and choose sprite mode 'Multiple'. Then, make sure you give the sprite a packing tag. Sprites with the same tag will be packed and batched together as soon as you run it in the Editor.

Note: You also have to set Edit > Project Settings > Editor > Sprite Packer Mode to 'Always Enabled'

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shopguy · Apr 04, 2014 at 02:36 AM 0
Share

I'll test this. Seems like one would want all in one batch, so always use same tag, unless this is subject to the max texture size in which case probably will not help me as my sprites are high res.

avatar image shopguy · Apr 04, 2014 at 02:48 AM 0
Share

Didn't test but read docs and looks like this will be subject to max texture sizes, so will not work in my case. $$anonymous$$ost of my sprite sheets are already 1024×1024 per object. Either a single building, or several poses of one animated character. I'll have about 20 of these to stay under 20mb in texture RA$$anonymous$$.

avatar image andrew-fray · Nov 19, 2014 at 04:00 PM 0
Share

This works as long as everything is in the same atlas. If you have sprites from atlas A at ordering 0 and 10, and some from atlas B at 5 and 15, the best you can hope for is four batches - A at 0, B at 5, A at 10, B at 15.

avatar image ickydime · Sep 25, 2017 at 07:43 PM 0
Share

Old thread but sprite mode of $$anonymous$$ultiple doesn't matter for batching. That just deter$$anonymous$$es if there should be multiple sprites within the texture you are inspecting. But you can still batch 2 single sprites that have the same packing tag. If you have multiple sprites within 1 texture then definitely have it on but it doesn't involve batching.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to implement Batching directly? 1 Answer

Why URP 2D sprite shader disable srp batcher? 0 Answers

Unity - Repack sprites at runtime 0 Answers

Display Part of a sprite 0 Answers

How should I move a sprite in a direction based on the rotation of a child? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges