Fast Loading Big Textures from File, Help!

Hi!

I’ve been stuck on this issue for quite awhile now. I’m doing a VR app for Mobile, and we need to load really big textures from files on the fly.

I’ve tried a variety of things, but every solution so far, has been slow. Currently, I’ve settled on using LoadRawTextureData with uncompressed files. This has given us a huge boost in terms of loading speed, but on the downside, it comes with Giant uncompressed files stored on users’ devices. And even then, the loading speed is still a touch too slow.

Is there any better way to do this? I’ve been scratching my head on this for months already. Please help!
Thanks everyone!

Well, more data takes more time. I did notice that loading in textures comes with a small freeze when the mipmaps are generated. If you use assetbundles instead, you can load in the textures including mipmaps and compression. There might still be some downloading time, but the freeze time is minimal, which is fairly important for VR. If I look at LoadRawTextureData, it should actually do pretty much the same, but using assetbundles might lead to cleaner code.

The second step would be to first load a lower resolution version and then later replace it with a higher resolution version. That way the texture displays very fast and gets better over time.

I’ve seen some web apis do what you mentioned. Definitely worth a shot seeing as I still haven’t found a solution to this. I’ll try that out as a temporary measure to improve the experience. Thanks!

As for assetbundles, that’s not really an option for me, as we have a cloud based system, where we upload the textures via webpanel, then download them to the phone from the server. Not sure how we would go about handling assetbundles with our current system.

However, it still wouldn’t solve the issue with the huge file sizes that I have with the uncompressed files.

You could try using Texture2D.Compress. But it’s rather slow,especially if you call it with true for high quality. That should reduce the memory footprint during runtime.

Regrettably, I have the same problem as you. Loading times can’t be improved so long as you’re loading files. Also the file type matters(PNGs are bigger, and like jvo3dc said, more data need more time). I guess the only way to improve this is for the job system to get released and at least be able to construct Texture2Ds through different threads than the main thread since it makes everything else so far sequential.

As far as the asset bundle approach goes, it’s actually a great idea. But it’s not a simple one. You have to refactor your codebase to work off of asset bundles and more importantly handle loading and unloading correctly. Also you probably need an extra license for Unity in order to create an asset bundle build farm. Basically, when you upload a new picture, you make sure to trigger some server with Unity installed, to run headless and build a new asset bundle with updated content and make sure its published in the cloud. You then just download that asset bundle and use it.
It’s also possible to introduce asset bundle variants for hi res and low res etc. Not to mention you could probably construct TextureAtlases out of your textures which cuts back on the mem footprint for all those large textures.
All sorts of optimizations become possible, but its a lot of work like I said.

AssetBundles are something that will stay on and will probably have a big team behind it,constantly being improved etc. So even if JobSystem gets released it’s probably a better idea for longterm to use ABs. Especially if they multithread the loading of AB content.

Personally, I’d really love to do so, but I can’t just yet.

Hey NPatch,

I’ve tried .Compress(), but last I did some R&D, .Compress() doesn’t work on Android. My Intention was actually to use .Compress() to generate DXT but think I had to use some external means for that.

The asset bundle farm might be the way to go. Though will have to take quite abit of R&D for that to happen at this point in time (which I do not have the time to allocate to).

Alas it’s all about time and resource! If only there was a magic solution I can use :slight_smile:

An asset bundle farm might be a good idea here too, but it is doable without that. It’s not that hard to at least script the whole bundle creation process and put that under a menu item. We’ve produced thousands of asset bundles this way.

@Spidlee

Even if it could, it would be a slow process. I’m noticing spikes even on Desktop(for my similar use case).

My problem as well. :roll_eyes:

@jvo3dc

As long as you’re familiar with it, then ok. But like any other feature it has its own quirks. You have to invest some time to familiarize yourself with it. Not to mention it might be a good idea to ponder the data layout of all those textures and/or other per-texture-data, or atlases etc. It has to load as fast as possible on mobile(at least on Spidlee’s case).
Also Unity does provide some code for getting started but it doesn’t mean you can’t optimize per case.And it seems in this case, you might need to, considering the scale of data.
I do agree though, it’s the way to go if you want to improve things.