- Home /
Best way to speed up loading texture from file
Hi,
Getting texture from www.texture makes my application freeze for some seconds (application requests from user uploading high resolution image), which depends on image size. As we know if image is non power of two, Unity does some extra calculation for copying texture and resize it to POT and it takes ages. Loading image which is power of two takes less than 100ms which is very good for me.
Conclusion: Loading time of NPOT is unfortunetly unacceptable.
Question: Is there ANY possibility, that I can make NPOT texture to load that fast as POT? Any method, sugestion would be great (even if I'd to write large amount of code in C or Java and treat that code as plugin for Unity3D).
Target OS is Android.
create an asset bundle (-s) with a textures imported by Unity and load them in bundles
http://docs.unity3d.com/Documentation/ScriptReference/AssetBundle.html
this should not use any additional converting/unpacking in runtime and store it packed.
If I get it right, I can't create asset bundle from image that is on user sdcard (i.e. his own photo_from_greece.jpg ).
To get this clear: I don't have ANY info what image will user upload to my app.
Anyway I found a workaround: I am doing the conversion using FreeImageNET, and I can get a color array out of that. So then I should just be able to use Texture2D.SetPixels.
i missed that this texture can be from unknown source 8)
so... where do you use this texture after loading? is it for geometry rendering with image as texture or just for GUI?
Just for some simple image processing, and render result as full screen quad.
if you will not use images on meshes, you needn't convert them to POT. did you try
http://docs.unity3d.com/Documentation/ScriptReference/WWW.LoadImageIntoTexture.html
?