Loading textures without freezing at runtime
I am in the process of developing an airplane simulator and so far so good, I have managed to make everything work nice, terrain mesh generation is working fast, etc. Now, I have come upon the problem of loading the ground textures. There are about 25,000 textures each being from 100kb to 2Mb in size at resolution 4096x4096. This is what it looks like (white square is a texture, colored smaller squares are meshes at different LODs):
When I try to do the following:
fileData = File.ReadAllBytes(filepath);
texture = new Texture2D(textureResolution, textureResolution);
texture.LoadImage(fileData);
There is about a 0.5 second freeze of main thread per texture. I intended to move this to another thread and let it load over time without blocking the game (new textures are loaded only every few minutes) but I can not find any good solutions.
Any ideas how to make this threaded? The only idea I have at the moment is to manually compress it to DXT1 and then use LoadRawTexture data, but that will probably still cause some freezes.
Your answer
Follow this Question
Related Questions
Can I set a solid background for a GUI label? 1 Answer
Unity does not save runtime changes to a texture 0 Answers
Image size increase on loading in memory from local storage? 1 Answer
Drawing texture using a different texture 1 Answer
Using BackgroundWorker with Unity, Completed not running on Main thread ? 1 Answer