Unity- Photosphere Photo Viewer for Google Cardboa

2019-01-21 08:47发布

问题:

I am trying to build a Photosphere-like application with Unity3D and use it along with Google cardboard.

I need to load different panoramic view photos and be able to view them stereoscopically, by using the Cardboard goggles.

I am having problem to use the pano images and render it into stereoscopic view in Unity.

Any suggestions will be gratefully received.

回答1:

Simplest solution that I can give to you:

A. Install your Unity Pro with Android Pro plugins, setup Cardboard SDK For Unity, install Android Build tools and SDK.

B Setup Skybox

  1. Get a stereoscopic panorama image (Might take a while to load the image as it is a high resolution image).

  2. In Unity, import the image, change the Texture Type to Cubemap. Select the Mapping as Cylindrical (Lat and Long).

  3. Create a Material, change the Shader to Skybox/Cubemap.

  4. Assign the texture to the material.

  5. In Unity 5 Pro topbar, select Window -> Ligthing, drag the material to the Skybox property. In this step you can do it programmatically. Combine these steps with the Cardboard assets and game objects. Voila, you've made a VR panorama stereoscopic Cardboard app! The whole setup is just take out your five minutes(excluding setup your tools :D).

If you're familiar with Unity, you know exactly what to do on my instructions. If you stuck at somewhere in my steps, feel free to ask me. Happy coding :)

Extra tips: You can make the large textures files into Asset Bundles, act like a dynamic content which is stored in the server. Your app is just simply a small-size empty app. When app launches, request and download the asset bundles from server then manipulate the textures. :)

Super extra tip: Don't forget to generate asset bundles under Android Build Settings. If not, your textures will be corrupted when the bundle is downloaded to Android phones.



回答2:

Make a sphere, write a shader so that it is not back culled and it can be seen from the inside. Use the pano image as a texture on the sphere. Place a VR camera rig in the center of the sphere. If you want true stereo, create two such spheres with separate textures for the left and right eye. Place the spheres at the lcoations of the cameras in the rig. Use layer culling so that each camera only sees the proper sphere.