play ricoh theta 360 videos in unity shanyuan teng

28
Project: Play 360 Videos in Unity By Shanyuan Teng https://github.com/tanyuan http://tengshanyuan.com/

Upload: theta-unofficial-guide

Post on 08-Jan-2017

250 views

Category:

Technology


1 download

TRANSCRIPT

Project:Play 360 Videos in Unity

By Shanyuan Tenghttps://github.com/tanyuanhttp://tengshanyuan.com/

Basic Idea Sphere: 360 Video

Camera

Install UnityPlease note that different versions of Unity are not compatible. You should export/import packages (.unitypackages) for cross versions. Export as packages before updating your Unity.

For this example: 5.3.4f1 Personal

Create a project

HierarchyGameObjects

InspectorGameObjectComponents

AssetsFiles

Unity is a 3D programming environment

Save the scene! (360Video.unity)Unity might crash at any time so please Ctrl + S / Cmd + S frequently.

1. Place the main camera to the origin (0, 0, 0)

2. Create a big sphere called VideoSphere that surrounds the camera

Unity default texture can only be seen from outside, so we need a custom

shader to make inside texture visible.

A material contains a texture (what to render) and a shader (how to render)

3. Create a folder Materials and create a material (360Video)

Drag material 360Video to Inspector of VideoSphere

4. Create a folder Shaders and create a shader (InsideVisible)

Double click to edit. Replace the code from the repo.

Drag InsideVisible to material of VideoSphere

5. Create a folder Videos, drag the video inside, and drag it to the material as texture.It might take a while importing videos to Assets. (even 10+ min)

Now we need to tell Unity to play the video texture.

We use the built-in MovieTexture.

6. Create an empty GameObject and name it VideoPlayback

Add a script VideoPlayback.cs to VideoPlaybackAdd Component > Create a C Sharp script > Edit Script

Paste the code from the repo.

6. Drag VideoSphere to SphereEvery public member will appear in Inspector.

7. Click play!You can live adjust Main Camera Position and Rotation to find other Pokémon.

Any adjustment in Play mode will be lost.Write down the value if you need to save for later use.

8. Play soundAdd Component > Audio Source > select Audio Clip as the same with the video

Stream from 360 cameraRicoh Theta S as an example

1. Switch to LIVE mode on Theta SWhile holding the camera icon button, press power button to go to LIVE stream mode. Then connect it to computer via USB.

2. Install RICOH THETA UVC Blender (Mac, Win)Richo Theta S captures dual fisheye views, while this driver can blend the two views into a single equirectangular view.

即時串流應用程式 https://theta360.com/ct/support/download/

RICOH THETA S - Dual Fisheye (native) THETA UVC Blender - Equirectangular (with driver)

2. Add a script (WebCamStream) to VideoPlaybackDrag the VideoSphere and specify Camera Number.

Device 0: RICOH THETA S Device 1: THETA UVC Blender Device 2: FaceTime HD Camera

Play once and check Unity console:

Uncheck

Check

Note: 360 Video on mobile devicesUnity built-in MovieTexture does not support mobile platforms (iOS, Android).

AVPro Video plugin ($450) provides good support for mobile and high resolution videos.