x


Converting downloaded texture into PVRTC on iPhone

I download a series of textures on the iPhone, using the WWW class.

When I download them they are RGBA format.

To conserve memory I want to change them into PVRTC.

How can I do this?

more ▼

asked Feb 17 '11 at 10:12 AM

rudolfwm gravatar image

rudolfwm
119 2 2 11

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

It's not going to happen, there is no functionality to compress to PVRTC at runtime, and it would take an extremely long time to do it anyway. (It's time-consuming enough on a desktop CPU, never mind mobile.)

more ▼

answered Feb 17 '11 at 11:31 AM

Eric5h5 gravatar image

Eric5h5
80k 41 132 518

Wow...then how am I going to deal with memory issues?

Feb 17 '11 at 11:33 AM rudolfwm

Use smaller textures?

Feb 17 '11 at 09:54 PM Eric5h5

Yes, Im doing that. However the quality of the texture is such that I cant go any lower.

Feb 18 '11 at 07:37 AM rudolfwm

I have an idea: can I not save those textures (theyre on my webserver) in the PVRTC format?

Feb 18 '11 at 07:38 AM rudolfwm

No, they can only be JPG or PNG. See the WWW.texture docs.

Feb 18 '11 at 08:01 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left

I have managed to solve this for Android. I think the same method can be applied for iOS as "the beef of the code" is relying upon standard OpenGL API.

I've uploaded a functional demo of my solution to this problem:

There are two projects:

  1. DynamicCompressedTextureTest - Unity project
  2. CompressedTextureLoader - Eclipse/Android project which contains the sources for "Assets/Plugins/Android/fi.jar"

One thing I'd like to ask from you: When one (or some) of you guys port this to iOS (I haven't yet taken the time), please send me a copy of the code (or post here)!

The idea:

  • Let Unity allocate and do the initial uploading of the compressed texture, the "TexturePlaceholder"
  • When new textures are needed, the placeholder is duplicated (GameObject.Instantiate()) and thus Unity allocates and manages the new copy of the compressed placeholder texture
  • Then, the Android code downloads a new compressed texture data in the background and once it's done, it simply overwrites the Unity managed texture - by uploading the downloaded data using Unity assigned texture ID.

At the time of writing, I didn't have a PowerVR equipped Android at my hands but I've made it working with PVRTC4 the same way some time ago. It's just about making sure that ...

  1. the TexturePlaceholder is compressed with the same method as the ones that are downloaded
  2. the Android code's texture format identifier is set correct
  3. the expected data lengths are set correct (bytes per pixel)

All in all, I think the code is fairly straight-forward, easy to read (not that elegant, though) and shows the common pitfalls to avoid.

I hope this helped, please let me know!

more ▼

answered Oct 21 '12 at 10:21 PM

codehead gravatar image

codehead
31 1 1 2

Wow, that's great. Thanks for sharing.

+1

Oct 21 '12 at 11:10 PM Bunny83
(comments are locked)
10|3000 characters needed characters left

I found the answer in the documentation (of course):

Texture2D lTexture = new Texture2D(lWidth, lHeight, TextureFormat. your format here, false);

// assign the downloaded image to the main texture of the object www.LoadImageIntoTexture(lTexture );

more ▼

answered Feb 17 '11 at 10:32 AM

rudolfwm gravatar image

rudolfwm
119 2 2 11

Actually, this results in lTexture converting to ARGB32!!!!!!

any ideas???

Feb 17 '11 at 11:15 AM rudolfwm
Feb 14 '12 at 08:10 AM codehead

Still no answer? Is it impossible? LoadImageIntoTexture does work with DXT1/5 on desktop, but not with PVRTC on iOS (and DTX1/5 are not supported)...

Oct 21 '12 at 03:34 PM luisanton
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2188
x1998
x524
x491
x51

asked: Feb 17 '11 at 10:12 AM

Seen: 1867 times

Last Updated: Oct 21 '12 at 11:10 PM