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
3
Question by Catlard · Sep 19, 2014 at 02:38 AM · 2dspritestexturesbackground

Unity 2D and Texture Memory.

I'm making a digital storybook, and I've got some very happy artists with some very large and CPU expensive textures (like, 4 background textures that are each 1024 x 512). So far, my advice for keeping it performant has been to:

1) make sure they're allowing unity to keep things as a power of two, 2) combining layers where possible 3) avoiding having images with lots of empty space 4) Making things static where possible.

But there's still no way it's going to look sharp on any iOS Retina screen, and have a good framerate. A friend suggested that making everything -- the characters, the backgrounds, everything -- into Unity 2D sprites -- would be vastly better. Is that true? Why?

Is there any other major performance-increasing thing I could do? Because right now Unity is seeming pretty slow for this kind of thing. I understand that Unity 2D will batch draw calls, but putting all my textures into one gigantic draw call wouldn't help, right? It's just putting all the eggs in one basket.

Comment
Add comment · Show 3
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 smoggach · Sep 19, 2014 at 02:49 AM 1
Share

I recently had to do this in Unity while porting a game from another engine (that had superior png decompression somehow). I resorted to using a loading animation that as it turns out is a great feature for our target audience. In your case however I'd advise your artists to indeed construct everything out of smaller sprites.

The reason is because this way you only load as much as the space you take up, and you can provide smaller images for non-retina devices ins$$anonymous$$d of having backgrounds for different aspect ratios.

However if your artists do want to draw the whole thing then it's best to confine them to the space of powers of two. It also helps to do that in layers even. I ended up having to use a tiled background with slightly smaller images layered on top for a small loading time decrease. However you can still achieve good loading times with proper compression. I've even heard people say it's better to use jpg for images with no transparency.

If you want to really get into the fastest way to load a texture I can provide an answer.

avatar image Catlard · Sep 19, 2014 at 03:48 AM 0
Share

Hi, smoggach! Thanks for the help. I know what you mean by using smaller sprites, and I plan to help them with that. That's good advice. BUT Do you think that the Unity 2D option will increase at all? Or no?

avatar image smoggach · Sep 19, 2014 at 12:50 PM 0
Share

Nope. The 2D option doesn't do much more than set the default main camera to orthographic. If you're super worried about performance you CAN shave a few milliseconds off by pooling sprite objects and just replacing their textures.

1 Reply

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

Answer by Eric5h5 · Sep 19, 2014 at 04:30 AM

some very large and CPU expensive textures (like, 4 background textures that are each 1024 x 512)

That has nothing to do with the CPU; textures are drawn by the GPU.

A friend suggested that making everything -- the characters, the backgrounds, everything -- into Unity 2D sprites -- would be vastly better. Is that true?

Nope. Sprites aren't magic and they're not even really 2D, they're the same 3D objects that everything in Unity is...textures on meshes. Having 4 background textures on quads vs 4 sprites is going to be pretty much the same, performance-wise. Using sprites makes sense simply because that's easier to work with, but won't significantly increase performance. Depending on what you're doing with the characters and what Unity license you have (Unity Pro can use tight meshes that save on fill rate), you can see some moderate performance improvements.

Anyway, 4 1024x512 textures is not very intensive even on mobile devices and will run quite fast. Just make sure to use a non-transparent shader (i.e., not the default sprite shader) on any textures that don't actually need transparency, to save on fill rate. Use compression where possible. It's usually better to use, say, a compressed 512x512 texture rather than a non-compressed 256x256 texture...you can visually scale down the compressed texture to make it look better and it will still use less RAM and be a little faster.

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 Catlard · Sep 19, 2014 at 06:07 AM 0
Share

Ah, yes, the old GPU CPU mixup. Thanks.

Darn. I didn't think sprites were magic, but I had my hopes. It sounds like it's still the right direction to go in.

As far as compression, I'm curious to hear your ideas on a concept. Would it be faster to run, say, a 512 x 512 image with an unlit shader and no transparency on a 50 tri mesh that is shaped to look like a partially transparent image? Or would it be faster to run a 512 x 512 image with transparency as a sprite? For example, let's say I compared:

1) A texture of a tree with transparency (the easier approach) on a quad, which uses an unlit sprite shader.

and

2) A UV map on a flat mesh cut to the shape of a tree, but which uses a non-transparent, unlit shader.

Is 2 still faster?

avatar image smoggach · Sep 19, 2014 at 12:59 PM 1
Share

Option 2 would work better because (since you don't need alpha) you could use JPG ins$$anonymous$$d of PNG which will load faster. However option 1 would work better on apple devices if you used PVR texture compression.

In any case Unity saves a lot of time on drawing with dynamic and static batching. In your position I'd choose whichever option is easiest for you and your artists.

avatar image Eric5h5 · Sep 20, 2014 at 12:49 AM 2
Share

You really do not want to use JPG, since it's lossy-compressed. It will not load any faster since Unity does not use JPG or PNG files (aside from the initial import in the editor).

The answer is, it depends. Not rendering pixels is faster than rendering them, of course, however rendering many polygons is slower than rendering few polygons. It's normally better to make some extra polygons if it means not rendering transparent pixels, since polygons are cheaper, but if you had really a lot of extra polygons, it could be slower. You'd have to test to know for sure.

avatar image Catlard · Sep 20, 2014 at 02:05 AM 0
Share

Great info, everybody. Sounds like something we'll have to test. Thanks!

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

26 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 avatar image avatar image avatar image avatar image

Related Questions

2d Platformer sprites background 1 Answer

Stretching Background sprite 4 Answers

2D Layout + 2D Spritesheets 0 Answers

What is the best way of creating a modular texture? 0 Answers

Is there any benefit to slicing in power of two dimensions inside a sprite sheet? 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