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
2
Question by Polynaut · Mar 08, 2011 at 09:04 PM · iphoneoptimizationimagesizepng

PNG / image optimization for iPhone

We're using Unity iPhone Pro for developing a 2D game.

We have approx. 120 backgrounds (Retina display resolution: 960x640 ergo 1024x1024 textures).

Since Apple has a 20 MB download restriction via 3G network, the final app need to be under this 20MB limit.

So we have optimized all PNG files in order to get them as small as possible. Compressed they are now all together under 10 MB - great!

But now comes Unity and blow up the whole thing - now we are somewhere above 20 MB only for the graphics. We know about this whole RGB / DXT5 stuff - but we don't want an optimization for the GPU, we want an optimization for the download size of our app. PVRTC isn't an option either - first it compresses badly concerning file size and second you get eye cancer watching the results.

Here some numbers to think about: A PNG file has approx. 50 kB per graphic - imported into Unity (as RGBA 32-bit) the same file is now 4 MB. Compressed in the final app the size of the PNG file would reduce to 45 kB while the compressed RGBA 32-bit file in the resource folder is 242 kB - five times the size of the original PNG file.

So PNG would be great - lossless compression, great optimization possibilities concerning file size and high quality results. But unfortunately Unity destroys all these advantages by converting it to a format suitable for the GPU but not for small file size (good for runtime performance but bad for the final app size).

The WWW.LoadImageIntoTexture method (which can load PNG files) is not an option either - it is to slow at runtime and produces an enormous memory overhead.

So does anybody know a way to keep the quality of the original images while compressing the images to the size of the compressed PNG files (or even smaller)?

Any help is appreciated! Thanks a lot.

Comment
Add comment
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

4 Replies

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

Answer by Eric5h5 · Mar 08, 2011 at 10:15 PM

The GPU does not use PNG, so it's impossible to use that format natively. You could try reading the files and parsing the PNG images yourself, but I'm not sure you can do better than LoadImageIntoTexture. Alternately, if you stick with uncompressed Unity formats, you can use 16 bit instead of 32 bit.

In any case, your game does not need to be under 20MB. Infinity Blade, for example, is well over 500MB, and there have been many popular games over 20MB. By far the best thing you can do for sales is to be featured by Apple, and it's harder to do impressive stuff under 20MB. None of the 50 million iPod touches sold can even use 3G (and most iPads are wifi too), and all iPhone owners can use wifi or download via iTunes, so it's generally a moot point.

Comment
Add comment · Show 1 · 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 HungryGames · Dec 11, 2015 at 01:33 AM 0
Share

Well, that's totally possible, just don't use GPU, there's a thing called CPU there... And then store in memory in any format you want. The issue here that Unity and it's editor don't support that approach, preloading PNG images into whatever it needs for the GPU.

avatar image
2

Answer by SuperSquawk · Dec 03, 2012 at 07:31 AM

I have the same problem, making a 2D game and compression is not an option, it makes the images unusable. The source images are less than 45MB but according to the editor log my images are being exported at almost 500MB!! The lossless PNG source files would work great on iOS (even though they are slower to load) due to the simple nature of the game I don't have performance problems. But a half Gig for 45MB of data is just insane. Where's the hidden option to use PNGs instead of whatever Unity uses by default?

Comment
Add comment · Show 1 · 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 MattRix · Dec 21, 2012 at 03:10 PM 0
Share

Unfortunately, there isn't an option like that, but there really should be.

avatar image
0

Answer by Renaldo-Goosen · Aug 27, 2012 at 12:56 PM

If you haven't yet. With your image selected, check in the Inspector and you'll see Import settings and on texture type select GUI. This vastly improves most image quality settings. (PNG too)

Comment
Add comment · 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
0

Answer by Bunny83 · Dec 21, 2012 at 03:27 PM

I guess you need one background at a time, so you just have to load one image. You could embed your images as TextAssets and load them manually with Texture2D.LoadImage. Of course loading in a png file and generating a texture out of it is not that fast, but there's no way around that. PNG is a zipped format and unpacking always takes some time.

As far as i remember you can control the generation of mipmaps and which format the loaded texture will use by specifying those when you create the Texture2D. Take a look at the TextureFormat. But keep in mind, as the docs on LoadImage stated, The format might change when you load the texture.

However if you need a certain format at runtime you can of course copy the texture to another texture with GetPixels32 and SetPixel32, but that's of course more processing overhead ;)

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

iPhone game build size minimum 3 Answers

PNG Build size is 40 times bigger than the Image file size 1 Answer

(2 hidden skinned meshes) or (1 extra draw call) for character props? 2 Answers

Loading a prefab over multiple frames. 1 Answer

Game build works fine in Android but is jittery in iPhone. 0 Answers


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