5

I've got two major problems with Unity (5.3.4p1) on GearVR with Samsung S6:

1) Async scene loading. Is there any change that I can load a new scene in background without seeing small freezes? Scene has ~60k triangles and uses a couple of 4k textures and ~10 other 2k textures. When this scene is loading there are multiple short freezes. I know I can avoid this by fading out to black and then starting loading level. But it takes ~10 seconds and user might be confussed seeing black screen for such long time with VR headset on.

2) Creating textures from images downloaded using WWW class. I use 360 4k image displayed on a dome in another scene. When I try to download a texture (4k, PNG or JPG) in runtime it's done asynchronously. But the Unity freezes for 2-3 seconds when I use:

Texture2D myTexture = www.texture;

Is there any option to avoid this other than use downloaded bytes and decompress JPG or PNG using non-Unity algorithm on background and then load created rgb values to a new texture? The good example of smooth texture loading can be seen in Flickr VR app but I doubt they used Unity to create this app.

This two problems occurs also on Oculus Rift but are less noticable because of much better PC performance.

Generally, I want to achieve smooth loading experience in Gear VR using Unity. Is this somehow possible?

jakub.sz
  • 63
  • 5

1 Answers1

3

This question should have been posted as two separate questions, but still:

AD 1: Add a small preloader scene, render that to the user and them load the main scene. Timewarp should still be working so head orientation changes will be visible.

AD 2: Android devices can't render jpeg or pngs. They have to decompress them to very large uncompressed textures, load to memory again and only then render. This takes both lots of ram and time.

What you can do is have the textures in the native DXT or ETC format and load them them as a texture yourself. I had the same issue and this has sped up loading my textures almost 10 times. They use less memory too.

Be warned that the download size will be bigger and depending on texture format you might have to have different files for different platforms.

Krzysztof Bociurko
  • 4,575
  • 2
  • 26
  • 44
  • ad 1: I'm doing it like this but there are still lots of small freezes when scene is loaded and it "jumps" a bit. ad 2: Samsung S6's GPU doesn't support DXT (tested it before) but I tried to do this with ASTC texture now. The problem is that the game freezes for 3-5 seconds when I apply the texure's bytes. I do it like this: `byte[] bytes = www.bytes;` `tex.LoadRawTextureData(bytes); ` `tex.Apply(false, false);` – jakub.sz Apr 12 '16 at 14:18
  • How can I avoid that? Is there any other way to download an image and load it to Unity texture? – jakub.sz Apr 12 '16 at 14:25
  • This should work, but I have never done this with ASTC textures. Perhaps there is some runtime conversion going on? Try ETC1, they are limited, but should work one every android device without additional processing. Also maybe setting the second argument to `tex.Apply` (`makeNoLongerReadable`) to true might help. As for my example with speeding things 10x up, this was on large sets of 2048x2048 and 1024x1024 textures, loaded one per frame, on Samsung Galaxy S II. It did of course take some time, but a few textures took less than a second to load. – Krzysztof Bociurko Apr 13 '16 at 05:49
  • And about other methods - there are assetbundles, maybe they will perform better? – Krzysztof Bociurko Apr 13 '16 at 05:50
  • Thanks a lot :) I've managed to get this to work and it's really fast now. I used ASTC (6x6 blocks and fast compression mode). Is there any way to find texture's width and height from downloaded data or should I use another (text) file with these properites saved? I still have to figure out how to load huge scene faster but at least one problem is gone now. – jakub.sz Apr 13 '16 at 06:43
  • 1
    With PVRTC and DXT I just parsed the header file, it was an simple struct. With ASTC the header is in [this whitepaper](http://malideveloper.arm.com/downloads/Stacy_ASTC_white%20paper.pdf), replicate these in a C# struct and use `Marshal.*` methods to copy the data from it. On a sidenote, I probably need to release these textureloaders on github or something, it's not the first time someone asks about these kind of things. – Krzysztof Bociurko Apr 13 '16 at 09:34
  • Thank you a lot! That was really helpful :) I also fixed the long scene loading by leaving Auto ASTC Unity compression and setting 6x6 40% by hand for all needed textures. In addition to that, after reducing resoultion for some of them scene loads 10-15 times faster than before :D – jakub.sz Apr 13 '16 at 12:21
  • For the next person coming across this: I was having display issues when loading the astc files created by astcenc. You have to skip the header bytes when using LoadRawTextureData. The header is 16 bytes long, so create a new byte array that doesn't include the first 16 bytes of www.bytes. – Jens Zalzala Feb 07 '18 at 17:53