- Home /
How to load a large texture at runtime without blocking the pipeline?
I understand that Apply() is not currently yieldable and I work in visualization where I need to load large textures (1k or 2k) at runtime. The loading is not a problem because WWW will do the job nicely in the background but making a Texture2D out of the data requires to go through Apply() at some point and that will block everything until it's done.
Is there a workaround for this? Can't this process of uploading to the graphics card be yielded/interrupted/fragmented/threaded/anything ?
Answer by Lucas Meijer 1 · Dec 30, 2009 at 04:59 PM
You can do this with assetbundles. They have a LoadAsync() method, which takes care of all the processor intensive stuff in a background thread, so it won't produce any hickups.
that does require your downloaded data to already be in the assetbundle format though.
Lucas, thank you very much for your reply. I wish Texture2D.LoadImage() was "aSyncable"... they obviously can do it so hopefully it's a matter of time. At the moment my only option is to have a Unity editor running and making asset bundles after downloading the large images.
Is there any way to make assetBundles outside the Editor ?
Thanks again.
A further note: this bottleneck happens regardless of whether you use Apply(), www.texture (which creates a Texture2D from the bytes), or www.LoadImageIntoTexture(). Alas, it appears we're two years down the road and no real improvement in this regard. The freeze on my fairly high-end machine is around 40-50 ms per megapixel loaded. We're trying to do a progressive disclosure / map tiling and it's definitely noticeable. Has anyone found any workarounds other than assetBundles in the Unity 3 series?