vr play 3d video

3d video playback
Principle: Mainly refer to this article: http://bernieroehl.com/360stereoinunity/
       3D video playback mainly renders each frame to the VR left and right eyes, the left eye takes the left half of each frame, and the right eye takes the right half. The key point is to solve how to divide each frame into left and right parts, and how to correspond the left and right eye cameras to the left and right frame images respectively.

Steps: 1 Import the package lrmap.unitypackage, which is a shader used to divide each frame of image into left and right or upper and lower parts according to the UV coordinate system.  
As indicated by the red pen, xy controls the left and right parts, and zw controls the upper and lower parts.
X=0 y=0.5 represents the left part x=0.5 y=1 represents the right half part.
     2 Add the left Quad: GameObject—3d Object – Quad Then drag the shader named tcUVcon extracted in 1 to this quad and modify the name of the quad to be left, and then modify the values ​​of x and y to 0, 0.5.
Add the right Quad, the same as above, just modify the name of the quad to right, and then modify the x and y values ​​to 0.5, 1
     3 Add two layers left, right, select the left Quad layer as left
In the same way, modify the right Quad and select the layer as right
     4 Select leftCameraT, select the culling mask as left,
Similarly, rightCameraT is selected as right.
     5 Create a new script MoivePlay3D.cs
         This cs is the same as MoviePlayerSample and needs to be modified as follows
  Comment out in Awake()
//if (GetComponent<Renderer>().material == null || GetComponent<Renderer>().material.mainTexture == null)
		//{
		//	Debug.LogError("Can't GetNativeTextureID() for movie surface");
		//}

Added in void Update()
    {
        //responseGamePadInput();
        //leftQuad.renderer.material.mainTexture=movieTex;
        if (texture == null)
        {
            Debug.Log("333333");
        }else
        {
            Debug.Log("444444");
            leftQuad.GetComponent<Renderer>().material.mainTexture = movieTex;
            rightQuad.GetComponent<Renderer>().material.mainTexture = movieTex;
        }
       
        //rightQuad.renderer.material.mainTexture = movieTex;
}

add global variable
public GameObject leftQuad, rightQuad;

Then drag the left and right quads to the leftQuad and rightQuad corresponding to the script respectively

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326693847&siteId=291194637