コード例 #1
0
ファイル: XRSystem.cs プロジェクト: reboot-an/Graphics
        // Used for camera stacking where we need to update the parameters per camera
        internal void UpdateFromCamera(ref XRPass xrPass, Camera camera)
        {
            if (xrPass.enabled && display != null)
            {
                display.GetRenderPass(xrPass.multipassId, out var renderPass);
                display.GetCullingParameters(camera, renderPass.cullingPassIndex, out var cullingParams);

                // Disable legacy stereo culling path
                cullingParams.cullingOptions &= ~CullingOptions.Stereo;

                if (xrPass.singlePassEnabled)
                {
                    xrPass = XRPass.Create(renderPass, multipassId: xrPass.multipassId, cullingParams, occlusionMeshMaterial);

                    for (int renderParamIndex = 0; renderParamIndex < renderPass.GetRenderParameterCount(); ++renderParamIndex)
                    {
                        renderPass.GetRenderParameter(camera, renderParamIndex, out var renderParam);
                        xrPass.AddView(renderPass, renderParam);
                    }
                }
                else
                {
                    renderPass.GetRenderParameter(camera, 0, out var renderParam);

                    xrPass = XRPass.Create(renderPass, multipassId: xrPass.multipassId, cullingParams, occlusionMeshMaterial);
                    xrPass.AddView(renderPass, renderParam);
                }
            }
        }
コード例 #2
0
ファイル: XRSystem.cs プロジェクト: sonilyan/Graphics
        // Used for camera stacking where we need to update the parameters per camera
        internal void UpdateFromCamera(ref XRPass xrPass, CameraData cameraData)
        {
            bool isGameCamera = (cameraData.camera.cameraType == CameraType.Game || cameraData.camera.cameraType == CameraType.VR);

            if (XRGraphicsAutomatedTests.enabled && XRGraphicsAutomatedTests.running && isGameCamera)
            {
                // XR test framework code path. Update 2nd view with camera's view projection data
                Matrix4x4 projMatrix        = cameraData.camera.projectionMatrix;
                Matrix4x4 viewMatrix        = cameraData.camera.worldToCameraMatrix;
                Rect      viewport          = new Rect(0, 0, testRenderTexture.width, testRenderTexture.height);
                int       textureArraySlice = -1;
                xrPass.UpdateView(1, projMatrix, viewMatrix, viewport, textureArraySlice);

                // Update culling params for this xr pass using camera's culling params
                cameraData.camera.TryGetCullingParameters(false, out var cullingParams);
                //// Disable legacy stereo culling path
                cullingParams.cullingOptions &= ~CullingOptions.Stereo;
                xrPass.UpdateCullingParams(0, cullingParams);
            }
            else if (xrPass.enabled && display != null)
            {
                display.GetRenderPass(xrPass.multipassId, out var renderPass);
                display.GetCullingParameters(cameraData.camera, renderPass.cullingPassIndex, out var cullingParams);
                // Disable legacy stereo culling path
                cullingParams.cullingOptions &= ~CullingOptions.Stereo;

                xrPass.UpdateCullingParams(cullingPassId: renderPass.cullingPassIndex, cullingParams);
                if (xrPass.singlePassEnabled)
                {
                    for (int renderParamIndex = 0; renderParamIndex < renderPass.GetRenderParameterCount(); ++renderParamIndex)
                    {
                        renderPass.GetRenderParameter(cameraData.camera, renderParamIndex, out var renderParam);
                        xrPass.UpdateView(renderParamIndex, renderPass, renderParam);
                    }
                }
                else
                {
                    renderPass.GetRenderParameter(cameraData.camera, 0, out var renderParam);
                    xrPass.UpdateView(0, renderPass, renderParam);
                }
            }
        }