- Home /
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?
Answer by Eric5h5 · Feb 17, 2011 at 11:31 AM
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.)
Yes, Im doing that. However the quality of the texture is such that I cant go any lower.
I have an idea: can I not save those textures (theyre on my webserver) in the PVRTC format?
No, they can only be JPG or PNG. See the WWW.texture docs.
Answer by codehead · Oct 21, 2012 at 10:21 PM
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:
- DynamicCompressedTextureTest - Unity project 
- 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 ...
- the TexturePlaceholder is compressed with the same method as the ones that are downloaded 
- the Android code's texture format identifier is set correct 
- 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!
Answer by rudolfwm · Feb 17, 2011 at 10:32 AM
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 );
Actually, this results in lTexture converting to ARGB32!!!!!!
any ideas???
I'm facing the same issue here. Please look at http://answers.unity3d.com/questions/184840/download-and-use-pvrtc-texture-ios.html#answer-217133
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)...
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                