public bool SetupForSingleCamera(float left, float right, float top, float bottom) { List <XRDisplaySubsystem> xrDisplayList = new List <XRDisplaySubsystem>(); SubsystemManager.GetInstances(xrDisplayList); if (xrDisplayList.Count != 1) { return(false); } XRDisplaySubsystem display = xrDisplayList[0]; if (display.GetRenderPassCount() != 1) { return(false); } display.GetRenderPass(0, out var renderPass); if (renderPass.GetRenderParameterCount() != 1) { return(false); } SetProjectionParamsForSingleCamera(left, right, top, bottom); Debug.Log($"{PluginMetadata.DebugLogPrefix}Sent single-cam projection parameters to native plugin."); return(true); }
private bool RenderingSingleCamera(Camera camera) { if (!running) { return(false); } // when this camera is rendering if (myCam != camera) { return(false); } // Our workaround is for single pass, single param rendering if (display == null) { return(false); } if (display.GetRenderPassCount() != 1) { return(false); } display.GetRenderPass(0, out var renderPass); return(renderPass.GetRenderParameterCount() == 1); }
void CreateLayoutFromXrSdk(Camera camera, bool singlePassAllowed) { bool CanUseSinglePass(XRDisplaySubsystem.XRRenderPass renderPass) { if (renderPass.renderTargetDesc.dimension != TextureDimension.Tex2DArray) { return(false); } if (renderPass.GetRenderParameterCount() != 2 || renderPass.renderTargetDesc.volumeDepth != 2) { return(false); } renderPass.GetRenderParameter(camera, 0, out var renderParam0); renderPass.GetRenderParameter(camera, 1, out var renderParam1); if (renderParam0.textureArraySlice != 0 || renderParam1.textureArraySlice != 1) { return(false); } if (renderParam0.viewport != renderParam1.viewport) { return(false); } return(true); } for (int renderPassIndex = 0; renderPassIndex < display.GetRenderPassCount(); ++renderPassIndex) { display.GetRenderPass(renderPassIndex, out var renderPass); display.GetCullingParameters(camera, renderPass.cullingPassIndex, out var cullingParams); // Disable legacy stereo culling path cullingParams.cullingOptions &= ~CullingOptions.Stereo; if (singlePassAllowed && CanUseSinglePass(renderPass)) { var xrPass = XRPass.Create(renderPass, multipassId: framePasses.Count, cullingParams, occlusionMeshMaterial); for (int renderParamIndex = 0; renderParamIndex < renderPass.GetRenderParameterCount(); ++renderParamIndex) { renderPass.GetRenderParameter(camera, renderParamIndex, out var renderParam); xrPass.AddView(renderPass, renderParam); } AddPassToFrame(xrPass); } else { for (int renderParamIndex = 0; renderParamIndex < renderPass.GetRenderParameterCount(); ++renderParamIndex) { renderPass.GetRenderParameter(camera, renderParamIndex, out var renderParam); var xrPass = XRPass.Create(renderPass, multipassId: framePasses.Count, cullingParams, occlusionMeshMaterial); xrPass.AddView(renderPass, renderParam); AddPassToFrame(xrPass); } } } }