Esempio n. 1
0
            /// <summary>
            /// Execute the render commands to blit the camera background texture.
            /// </summary>
            /// <param name="context">The render context for executing the render commands.</param>
            /// <param name="renderingData">Additional rendering data about the current state of rendering.</param>
            public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
            {
                var cmd = CommandBufferPool.Get(k_CustomRenderPassName);

                ARCameraBackground.AddOpenGLES3ResetStateCommand(cmd);
                cmd.SetInvertCulling(m_InvertCulling);
                Blit(cmd, m_Texture, m_ColorTargetIdentifier, m_Material);
                context.ExecuteCommandBuffer(cmd);

                CommandBufferPool.Release(cmd);
            }
        /// <summary>
        /// Add the background rendering pass when rendering a game camera with an enabled AR camera background component.
        /// </summary>
        /// <param name="renderer">The sriptable renderer in which to enqueue the render pass.</param>
        /// <param name="renderingData">Additional rendering data about the current state of rendering.</param>
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
#if !UNITY_EDITOR
            Camera currentCamera = renderingData.cameraData.camera;
            if ((currentCamera != null) && (currentCamera.cameraType == CameraType.Game))
            {
                ARCameraBackground cameraBackground = currentCamera.gameObject.GetComponent <ARCameraBackground>();
                if ((cameraBackground != null) && cameraBackground.backgroundRenderingEnabled && (cameraBackground.material != null))
                {
                    m_ScriptablePass.Setup(cameraBackground.material, renderer.cameraColorTarget, renderer.cameraDepth);
                    renderer.EnqueuePass(m_ScriptablePass);
                }
            }
#endif // !UNITY_EDITOR
        }
Esempio n. 3
0
        /// <summary>
        /// Add the background rendering pass when rendering a game camera with an enabled AR camera background component.
        /// </summary>
        /// <param name="renderer">The scriptable renderer in which to enqueue the render pass.</param>
        /// <param name="renderingData">Additional rendering data about the current state of rendering.</param>
        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
#if !UNITY_EDITOR
            Camera currentCamera = renderingData.cameraData.camera;
            if ((currentCamera != null) && (currentCamera.cameraType == CameraType.Game))
            {
                ARCameraBackground cameraBackground = currentCamera.gameObject.GetComponent <ARCameraBackground>();
                if ((cameraBackground != null) && cameraBackground.backgroundRenderingEnabled &&
                    (cameraBackground.material != null))
                {
                    bool invertCulling = cameraBackground.GetComponent <ARCameraManager>()?.subsystem?.invertCulling ?? false;
                    m_ScriptablePass.Setup(m_BackgroundMesh, cameraBackground.material, invertCulling);
                    renderer.EnqueuePass(m_ScriptablePass);
                }
            }
#endif // !UNITY_EDITOR
        }
Esempio n. 4
0
            /// <summary>
            /// Execute the commands to render the camera background.
            /// </summary>
            /// <param name="context">The render context for executing the render commands.</param>
            /// <param name="renderingData">Additional rendering data about the current state of rendering.</param>
            public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
            {
                var cmd = CommandBufferPool.Get(k_CustomRenderPassName);

                cmd.BeginSample(k_CustomRenderPassName);

                ARCameraBackground.AddOpenGLES3ResetStateCommand(cmd);
                cmd.SetInvertCulling(m_InvertCulling);

                cmd.SetViewProjectionMatrices(Matrix4x4.identity, k_BackgroundOrthoProjection);
                cmd.DrawMesh(m_BackgroundMesh, Matrix4x4.identity, m_BackgroundMaterial);
                cmd.SetViewProjectionMatrices(renderingData.cameraData.camera.worldToCameraMatrix,
                                              renderingData.cameraData.camera.projectionMatrix);

                cmd.EndSample(k_CustomRenderPassName);
                context.ExecuteCommandBuffer(cmd);

                CommandBufferPool.Release(cmd);
            }