• Home  / 
  • Unity3D
  •  /  How to play Stereoscopic 3D 360 Video in VR with Unity3D

How to play Stereoscopic 3D 360 Video in VR with Unity3D

If you’ve played 360 video in VR, you know it’s kinda cool… But lately, 3D video is starting to take off.  With off the shelf cameras like the Vuze line, it’s gotten easy to record your own without spending the cost of a new car to get started..  Before today, playing 360 3D video in VR with Unity3D was a bit complicated.. but now, thanks to an open source project put out by Unity Technologies, it’s getting easier.  Earlier today, I stumbled on a post and github project they’ve put together to make 3D 360 video simple to implement.

Video Version

Prefer to watch video?  The entire process is available on youtube here.

Project Setup

To get going, you’ll need a couple things..  First, you need a 3D video.  For this article, I’m using an Over-Under video you can download from here: http://www.panocam3d.com/video3d360.html#!portfolio/project-13.html

Once you’ve downloaded your video, you’ll need to grab the script and shader from this github project: https://github.com/Unity-Technologies/SkyboxPanoramicShader

You can download it or clone the repository, whatever you feel most comfortable doing.

Place the shader and script into your project along with the video file you want to play.

You’ll also need to visit your player settings and make sure the Virtual Reality Enabled box is checked.

Render Texture

To use this shader, we need a render texture.  Create a new render texture and name it “Panoramic Render Texture”

Select the RenderTexture and change the size to 2304 x 2304.

The render texture resolution should match your video resolution.

Change the depth buffer to “No depth buffer”.

Render textures are textures that can be rendered to. They can be used to implement image based rendering effects, dynamic shadows, projectors, reflections or surveillance cameras.

The Video Player

To create a video player, drag the video from the project view into the scene view.  A player will automatically be created with the video assigned to it.

Select the video player and look to the inspector.

Change the render mode to “Render Texture”.

Drag the render texture from the project view into the target texture field.

The Material

Next, we need to create a material for the shader.

Create a new material, name it “Skybox”

Drag the render texture onto it.

Set the mapping type to “Latitude Longitude Layout”

Change the image type to 360 Degrees.

Set the 3D layout to “Over Under”

Skybox Setup

The last step is to assign our material to the skybox.

Open the Lighting window.

Drag the Skybox into the Skybox Material field.

All Done

That’s it, save your scene…

Then put on the headset and press play, the video should start playing in 3D.

What about other video types?

This shader appears to have support for a few different video formats.  In this article, we covered a simple 360 degree over under video, but you may have noticed the options for 180 & side by side.  I haven’t tried those yet, but if you’re interested in them, I’d recommend you check out the full documentation they’ve provided here: https://docs.google.com/document/d/1JjOQ0dXTYPFwg6eSOlIAdqyPo6QMLqh-PETwxf8ZVD8/edit#

  • Toulouse de Margerie

    Awesome tutorial Jason!

    I’m glad you’re enjoying the GitHub beta project we’ve provided (I’m the author by the way)

    I wanted to make two suggestions:

    1) Whenever you are using the Video Player’s Render Texture mode it is best to set the Render Texture dimensions to match the video clip dimensions exactly (visible if you select the video clip and check the Inspector). This will provide maximum visual fidelity and also best performance.

    2) The video you chose is actually a “regular” stereo video which isn’t quite the same thing as a 180 degree video. You’ll notice the video will feel quite zoomed-in and the 3D will get a little funky at the top and bottom of the video. The fact that you chose a 4096×4096 RT dimension mitigates this because the video ends up mostly filling the texture with black at the top and bottom where you would see this type of distortion.

    I highly recommend you give this a try with some 360 video from YouTube such as https://www.youtube.com/watch?v=G-XZhKqQAHU I recommend you initially refrain from trying to use full 4K sized video (maybe stick with 1080p or so at first) as many hardware setups have difficulty playing such large resolutions. Also, note that as far as I can see, YouTube doesn’t host any 180 degree video, just 360.

    • Wow thanks for this, that makes a lot of sense and really helps. Gonna go in and do some updates asap.

      And thanks for the github project, you’re making this stuff so much easier!

    • JW

      Thanks for the feedback, that was really helpful. And thanks for writing the source that makes this all possible!

      I’ve rebuilt the guide to use a real 360 3D video, modified the render texture section, and it’s working great 🙂

      Thanks again!

    • Pratham Sehgal

      Hey Toulouse
      But Youtube videos are not yet supported to work as a URL in Unity editor and there is a problem with playing most videos hosted online as well.. How to play the videos online to stream/download on the device when the user requires it like most of the applications do? Is there a specific way to host a video in order to play it via an online URL?

      • Toulouse de Margerie

        Hi Pratham,

        You are correct that Unity’s native Video Player does not yet support YouTube or other streaming services. For the time being, we only support playback of supported file types streamed directly from a server (eg. an .mp4 file hosted somewhere online).

        Jason, had originally posted his tutorial with instructions for how to download video from YouTube for use in his Unity project which is why I had suggested a different 360 video for him to try out.

        Perhaps Jason wants to chime in and comment on the method he found for downloading video from YouTube.

        • Pratham Sehgal

          Yeah. I saw the tutorial.
          I was just wondering as I’m trying to reduce the size of the application I’m currently working on by streaming the 360 degree videos online but it so happens that a lot of these hosting sites do not actually give you the access of the files hosted but rather play it on their own player which again is not supported by Unity.
          So I’m trying to figure out the best solution to host the media online without really blowing the budget.

    • JW

      Thanks for this feedback btw, I re-wrote the post and the redid the video with all your feedback and I think it’s a lot better now.

      Also of course thanks again for building the source behind this! Great work and really appriciated!

      • Toulouse de Margerie

        Looks great Jason!
        Thanks again for your interest in the project!

  • Pingback: Building an Interactive Mobile 360 Video Player for GearVR - Unity3D.College()

  • Pingback: 360 Video in Unity 5.6 - Unity3D.College()

  • David Broggy

    I didn’t have audio. I had to strip out the audio and load it as a separate component. Did I miss something or was that step missed? Great tutorial thanks.