浏览代码

Generate stereo and forward-rendering state in HDCamera

Stereo is enabled on a per-camera basis, if stereo is generally active and the camera can render to both eyes.

Additionally, the HDCamera itself will start storing the forward-only state as stereo rendering will be forward only for HDRP (for now).
/main
Robert Srinivasiah 7 年前
当前提交
aae9568f
共有 2 个文件被更改,包括 13 次插入5 次删除
  1. 14
      ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs
  2. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs

14
ScriptableRenderPipeline/HDRenderPipeline/Camera/HDCamera.cs


// avoid one-frame jumps/hiccups with temporal effects (motion blur, TAA...)
public bool isFirstFrame { get; private set; }
public bool useForwardOnly { get; private set; }
public bool stereoEnabled { get; private set; }
public Vector4 invProjParam
{
// Ref: An Efficient Depth Linearization Method for Oblique View Frustums, Eq. 6.

Reset();
}
public void Update(PostProcessLayer postProcessLayer)
public void Update(PostProcessLayer postProcessLayer, GlobalRenderingSettings globalRenderingSettings, bool stereoActive)
{
// If TAA is enabled projMatrix will hold a jittered projection matrix. The original,
// non-jittered projection matrix can be accessed via nonJitteredProjMatrix.

frustumPlaneEquations[5] = new Vector4(-camera.transform.forward.x, -camera.transform.forward.y, -camera.transform.forward.z, Vector3.Dot(camera.transform.forward, relPos) + camera.farClipPlane);
m_LastFrameActive = Time.frameCount;
stereoEnabled = stereoActive && (camera.stereoTargetEye == StereoTargetEyeMask.Both);
useForwardOnly = globalRenderingSettings.ShouldUseForwardRenderingOnly() || stereoEnabled;
}
public void Reset()

stereoEnabled = false;
useForwardOnly = false;
public static HDCamera Get(Camera camera, PostProcessLayer postProcessLayer)
public static HDCamera Get(Camera camera, PostProcessLayer postProcessLayer, GlobalRenderingSettings globalRenderingSettings, bool stereoActive)
{
HDCamera hdcam;

s_Cameras.Add(camera, hdcam);
}
hdcam.Update(postProcessLayer);
hdcam.Update(postProcessLayer, globalRenderingSettings, stereoActive);
return hdcam;
}

4
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


m_FrameCount = Time.frameCount;
}
var stereoEnabled = UnityEngine.XR.XRSettings.isDeviceActive && m_CurrentDebugDisplaySettings.renderingDebugSettings.allowStereo;
var stereoActive = UnityEngine.XR.XRSettings.isDeviceActive && m_CurrentDebugDisplaySettings.renderingDebugSettings.allowStereo;
foreach (var camera in cameras)
{

renderContext.SetupCameraProperties(camera);
var postProcessLayer = camera.GetComponent<PostProcessLayer>();
var hdCamera = HDCamera.Get(camera, postProcessLayer);
var hdCamera = HDCamera.Get(camera, postProcessLayer, m_Asset.globalRenderingSettings, stereoActive);
PushGlobalParams(hdCamera, cmd, sssSettings);
// TODO: Find a correct place to bind these material textures

正在加载...
取消
保存