Samsung / GearVRf

The GearVR framework(GearVRf) is an Open Source VR rendering library for application development on VR-supported Android devices.
http://www.gearvrf.org
Apache License 2.0
407 stars 217 forks source link

Bad quality with texture on GVRSphereSceneObject #695

Closed EnricoOri closed 8 years ago

EnricoOri commented 8 years ago

I'm working at a simple 360 photo viewer with some POIS to click but I'm seeing bad quality 360 photos even with very big and high quality pictures (10000 x 5000)

I used the code from the "gvr-360photo" sample and added a bit of scale but it looks very pixellated.

Future<GVRTexture> texture = gvrContext.loadFutureTexture(new GVRAndroidResource(gvrContext, R.drawable.provahires));
        sphereObject = new GVRSphereSceneObject(gvrContext, false, texture);
        sphereObject.getTransform().setScale(50, 50, 50);
        sphereObject.getRenderData().setRenderingOrder(1);
        scene.addSceneObject(sphereObject);

Is there something i'm missing to show the picture in good quality?

thomasflynn commented 8 years ago

The images are automatically getting scaled down. I encountered this myself two weeks back or so. I have some tweaks in my tree that i haven't yet converted into a pull request. I'll do that today. Even given those tweaks though, i still ran into a memory limit on android. Even when you request a large heap, you still are only given 512 megs to use (a normal heap is 256 megs). Your image will decompress to width x height x 4 bytes. If that's larger than what you have to work with, the image will need to be scaled down to fit into memory. Thankfully, the image i was working with (originally 16k x 8k, scaled down to 8k x 4k) still looked very good at the scaled down resolution.

EnricoOri commented 8 years ago

Thank you I will check your fork!

thomasflynn commented 8 years ago

I haven't committed the changes to any of my branches yet. Again, i'll do that in a few hours. It's actually sitting as local changes on my master branch on my machine at work (i'm currently st home in bed on my phone :). If you're impatient, i think i can remember two of the key changes. Let me browse the repo real quick...

EnricoOri commented 8 years ago

Don't worry, take your time, just please let me know when you have commited the changes so i could download it and try it. Thanks in advance.

thomasflynn commented 8 years ago

Ok, in GVRAsyncBitmapTexture.javs in the asynchronous/ directory: 1) There's a bug with our detection and handling of MAX_TEXTURE_SIZE. When i was debugging it, we actually detect it correctly, but it somehow gets overwritten by the default we set (1024). I changed the default to the max texture size on s7 (16384) since that's what i was debugging on. This needs to be fixed properly.

2) there's a MAX_IMAGE_FACTOR that's set to .125. That the fraction of the maximum amount of memory you have available. I fudged that to something like .625 or .75 or something.

3) there's a call to activityManager.getMemoryClass() to determine our heap size. I changed that to getLargeMemoryClass() or something. If you do this, you also need to request a "largeheap" in your AndroidManifest.xml. how to flexibly, and properly handle this? I'm not sure. Will have to discuss it with some people.

EnricoOri commented 8 years ago

@thomasflynn I tried with your changes but the sphere appears to be black, is like it can't render it. I'll wait for your fork to be committed, maybe I changed something in the wrong way.

PS. I'm debugging on a OnePlusOne on mono and on a Galaxy S7 Edge with the GearVR

Thanks

thomasflynn commented 8 years ago

ok, committed my changes to a branch here: https://github.com/thomasflynn/GearVRf/tree/bigphoto

all the changes are in that GVRAsyncBitmapTexture.java file

EnricoOri commented 8 years ago

Works really well! I find out also found out 8192 to be a good result. Thank you very much.

liaxim commented 8 years ago

@dlockh3ll Can we close the issue then? Thanks.

thomasflynn commented 8 years ago

i wouldn't close this yet. i need to put proper fixes in my branch and do a pull request.

thomasflynn commented 8 years ago

proper fixes are up in https://github.com/Samsung/GearVRf/pull/709

liaxim commented 8 years ago

Pull request has been merged