Ejemplo n.º 1
0
        /// <summary>
        /// Default allocator method for XRPass.
        /// </summary>
        /// <param name="createInfo"></param>
        /// <returns></returns>
        public static XRPass CreateDefault(XRPassCreateInfo createInfo)
        {
            XRPass pass = GenericPool <XRPass> .Get();

            pass.InitBase(createInfo);
            return(pass);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Populate and upload shader constants used by the C++ builtin renderer.
        /// This is required to maintain compatibility with legacy code and shaders.
        /// </summary>
        /// <param name="xrPass"></param>
        /// <param name="cmd"></param>
        /// <param name="renderIntoTexture"></param>
        public static void Update(XRPass xrPass, CommandBuffer cmd, bool renderIntoTexture)
        {
#if ENABLE_VR && ENABLE_XR_MODULE
            if (xrPass.enabled)
            {
                cmd.SetViewProjectionMatrices(xrPass.GetViewMatrix(), xrPass.GetProjMatrix());

                if (xrPass.singlePassEnabled)
                {
                    for (int viewIndex = 0; viewIndex < 2; ++viewIndex)
                    {
                        s_cameraProjMatrix[viewIndex] = xrPass.GetProjMatrix(viewIndex);
                        s_viewMatrix[viewIndex]       = xrPass.GetViewMatrix(viewIndex);
                        s_projMatrix[viewIndex]       = GL.GetGPUProjectionMatrix(s_cameraProjMatrix[viewIndex], renderIntoTexture);
                        s_viewProjMatrix[viewIndex]   = s_projMatrix[viewIndex] * s_viewMatrix[viewIndex];

                        s_invCameraProjMatrix[viewIndex] = Matrix4x4.Inverse(s_cameraProjMatrix[viewIndex]);
                        s_invViewMatrix[viewIndex]       = Matrix4x4.Inverse(s_viewMatrix[viewIndex]);
                        s_invProjMatrix[viewIndex]       = Matrix4x4.Inverse(s_projMatrix[viewIndex]);
                        s_invViewProjMatrix[viewIndex]   = Matrix4x4.Inverse(s_viewProjMatrix[viewIndex]);

                        s_worldSpaceCameraPos[viewIndex] = s_invViewMatrix[viewIndex].GetColumn(3);
                    }

                    cmd.SetGlobalMatrixArray(unity_StereoCameraProjection, s_cameraProjMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoCameraInvProjection, s_invCameraProjMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoMatrixV, s_viewMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoMatrixInvV, s_invViewMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoMatrixP, s_projMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoMatrixInvP, s_invProjMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoMatrixVP, s_viewProjMatrix);
                    cmd.SetGlobalMatrixArray(unity_StereoMatrixInvVP, s_invViewProjMatrix);
                    cmd.SetGlobalVectorArray(unity_StereoWorldSpaceCameraPos, s_worldSpaceCameraPos);
                }
            }
#endif
        }
Ejemplo n.º 3
0
 internal XROcclusionMesh(XRPass xrPass)
 {
     m_Pass = xrPass;
 }