This project is no longer actively maintained by the Google Creative Lab but remains here in a read-only Archive mode so that it can continue to assist developers that may find the examples helpful. We aren’t able to address all pull requests or bug reports but outstanding issues will remain in read-only mode for reference purposes. Also, please note that some of the dependencies may not be up to date and there hasn’t been any QA done in a while so your mileage may vary.
For more details on how Archiving affects Github repositories see this documentation . We welcome users to fork this repository should there be more useful, community-driven efforts that can help continue what this project began. |
Sprayscape is a perfectly imperfect VR-ish camera. It is an open source Android app released on the Android Experiments platform.
Sprayscape is built in Unity with native Android support. Using the Google VR SDK for Unity to handle gyroscope data and the NatCam Unity plugin for precise camera control, Sprayscape maps the camera feed on a 360 degree sphere.
The GPU makes it all possible. On user tap or touch, the camera feed is rendered to a texture at 60 frames per second. That texture is then composited with any existing textures by a fragment shader on the GPU. That same shader also handles the projection from 2D camera to a 360 sphere, creating the scape you see in app.
When a user saves a scape, a flat panorama image is stored in the app data and written to a single atlas file containing all scapes. The atlas is loaded into the scapes view the gallery of scapes with gyro navigation.
Sharing is handled by native Android code. When a user shares a scape via link, users sign-in with Google OAuth and are prompted for read and write access on Drive. All user generated content is stored on a user’s Drive account so users can delete their content at any time. With permissions in place, the Drive API v3 checks for a Sprayscape folder, creates one if lacking, and uploads the file. A share URL is presented to the user in a Native Share dialog and is also attached to the scape object on the app for easy sharing at a later date.
Facebook share is also handled natively. The panorama is prepared as an image object with appropriate EXIF data to insure proper presentation on Facebook and then presented to the user via Native Share. User selects Facebook to share to their networks.
The web viewer is built using WebGL, Three, and the emerging WebVR spec via the polyfill developed at Google by Boris Smus. Using these open standards allows for an adaptive experience across desktops, tablets, and phones. WebVR support means Sprayscape’s web experience is ready for VR devices: Cardboard, Daydream, Vive, and Oculus. Additional UI and state management is handled by the lightweight Choo framework.
Some elements are not in the repository, and need to be setup before the Unity project can be built.
Sprayscape/Assets/NatCam
Secrets.cs
contains the hashing key for sharing. There is a sample file for creating it called Sprayscape/Assets/Scripts/Secrets.cs.sample
that you can rename. After these steps the app should be ready to be built and run on your device.
Brian Kehrer, Troy Lumpkin, Dan Motzenbecker, Jeramy Morrill, James Vecore, Norm McGarry, Chris Parker, Celso de Melo, Jonas Jongejan, Glenn Cochon, Brendon Avalos, Ryan Burke