سؤال

I'm using Unity3d (4.3.1) and NGUI for creating an 2d iOS (iPad) app. Also I need to use a lot of full screen images (about 100 images with size 2048x1536), for Gallery for example. Now I'm using them with GUI type, override for iPhone with max size 2048 and compression quality: normal. And I'm using a UITexture with Unlit/Transparent shader to show them.

However, after about 40 images in the project XCode returns the terminated due to memory error. So the question is, what type of images do I need, and with which preferences to make them work?

I'm using iPad 3 as a test device with XCode 5.1.1. I'll be thankful for any help!

هل كانت مفيدة؟

المحلول

Also I need to use a lot of full screen images (about 100 images with size 2048x1536), for Gallery for example.

I think your 2048x2048 size images use a very huge memory area. Basically, 2048 image use 16MB memory. So, this case need to use about a 1600MB memory! Normal application don't over about 200 MB.

So, I think you need to be reduce using a memory:

  1. Remember that this texture is going to be expand 2048x2048 by unity.( http://www.opengl.org/wiki/NPOT_Texture ) So, if you are going to reduce file size to 1500x1000, your application still use 2048x2048 image. But if you can reduce file size to 1024x1024, do it. 1024 image just use 4 MB memory.

  2. If you can use texture compression. Use it. PVRTC 4 bit ( https://docs.unity3d.com/Documentation/Manual/ReducingFilesize.html ) compression is make file size 1/8 than true color. Also memory size is going to reduce.(maybe reduced to half)

  3. If your application don't display all images, load image dynamically. Use thumb nail.

Good luck:D

نصائح أخرى

If you want to make a gallery-like app to render photos maybe you can try a different approach:

  • create two large editable textures and fill texels with image data (it must be editable otherwise you will no have access to write directly image data into them).
  • if you still have memory issues or if you want to use lower memory you can use several smaller textures as tiles. You can render then image parts to each smaller texture. Remember to configurate correctly the texture borders or so not use border texels to avoid wrapping problems.

Best way is to use a smaller texture. In an ipad you will need a magnifying glass to really appreciate the difference between 1024x1024 and larger textures. Remember an ipad screen is smaller (7"~10") than a computer one and with filtering enabled is really hard to tell the difference.

If you still need manager such a large texture for some other reason (zooming or similar) I recommend you one of the following approaches:

  • split the texture into layers with alpha channel (transparency): usually backgrounds can be rendered with lower resolutions.
  • split also the texture into blocks: usually most textures have repeating patterns.
  • use compression.

Always avoid use such large textures if possible.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top