浏览代码

Most basic support for XR in SRP

The most barebones version of XR support in SRP is just using the new APIs to stereo-ize culling, render setup (matrices, viewports, RTs), and draws.
/RenderPassXR_Sandbox
robbiesri 7 年前
当前提交
8175f17d
共有 1 个文件被更改,包括 19 次插入2 次删除
  1. 21
      Assets/ScriptableRenderPipeline/BasicRenderPipeline/BasicRenderPipeline.cs

21
Assets/ScriptableRenderPipeline/BasicRenderPipeline/BasicRenderPipeline.cs


using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityEngine.XR;
// Very basic scriptable rendering loop example:
// - Use with BasicRenderPipelineShader.shader (the loop expects "BasicPass" pass type to exist)

public static void Render(ScriptableRenderContext context, IEnumerable<Camera> cameras)
{
bool stereoEnabled = XRSettings.isDeviceActive;
if (!CullResults.GetCullingParameters(camera, out cullingParams))
// Stereo-aware culling parameters are configured to perform a single cull for both eyes
if (!CullResults.GetCullingParameters(camera, stereoEnabled, out cullingParams))
continue;
CullResults cull = new CullResults();
CullResults.Cull(ref cullingParams, context, ref cull);

context.SetupCameraProperties(camera);
// If stereo is enabled, we also configure stereo matrices, viewports, and XR device render targets
context.SetupCameraProperties(camera, stereoEnabled);
// Draws in-between [Start|Stop]MultiEye are stereo-ized by engine
if (stereoEnabled)
context.StartMultiEye(camera);
// clear depth buffer
var cmd = CommandBufferPool.Get();

settings.sorting.flags = SortFlags.CommonTransparent;
settings.inputFilter.SetQueuesTransparent();
context.DrawRenderers(ref settings);
if (stereoEnabled)
{
context.StopMultiEye(camera);
// StereoEndRender will reset state on the camera to pre-Stereo settings,
// and invoke XR based events/callbacks.
context.StereoEndRender(camera);
}
context.Submit();
}

正在加载...
取消
保存