浏览代码

Fix post-merge issues with new Frustum struct

Bonus: I don't need to pass Camera into my stereo HDCamera state override function
/main
Robert Srinivasiah 7 年前
当前提交
64e65354
共有 2 个文件被更改,包括 6 次插入17 次删除
  1. 21
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

21
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs


screenSize = new Vector4(screenWidth, screenHeight, 1.0f / screenWidth, 1.0f / screenHeight);
}
public void UpdateStereoDependentState(FrameSettings frameSettings, Camera camera, ref ScriptableCullingParameters cullingParams)
public void UpdateStereoDependentState(FrameSettings frameSettings, ref ScriptableCullingParameters cullingParams)
{
if (!frameSettings.enableStereo)
return;

// TODO: I really should be calculating my own combined view/proj in the Update code
var stereoCombinedViewMatrix = cullingParams.cullStereoView;
var pos = camera.transform.position;
var relPos = pos; // World-origin-relative
relPos = Vector3.zero; // Camera-relative
}
viewMatrix = stereoCombinedViewMatrix;

viewParam = new Vector4(viewMatrix.determinant, 0.0f, 0.0f, 0.0f);
// Warning: near and far planes appear to be broken (or rather far plane seems broken)
GeometryUtility.CalculateFrustumPlanes(viewProjMatrix, frustumPlanes);
frustum = Frustum.Create(viewProjMatrix, true, true);
for (int i = 0; i < 4; i++)
// Left, right, top, bottom, near, far.
for (int i = 0; i < 6; i++)
// Left, right, top, bottom.
frustumPlaneEquations[i] = new Vector4(frustumPlanes[i].normal.x, frustumPlanes[i].normal.y, frustumPlanes[i].normal.z, frustumPlanes[i].distance);
frustumPlaneEquations[i] = new Vector4(frustum.planes[i].normal.x, frustum.planes[i].normal.y, frustum.planes[i].normal.z, frustum.planes[i].distance);
// Near, far.
Vector4 forward = new Vector4(camera.transform.forward.x, camera.transform.forward.y, camera.transform.forward.z, 0.0f);
// We need to switch forward direction based on handness (Reminder: Regular camera have a negative determinant in Unity and reflection probe follow DX convention and have a positive determinant)
forward = viewParam.x < 0.0f ? forward : -forward;
frustumPlaneEquations[4] = new Vector4(forward.x, forward.y, forward.z, -Vector3.Dot(forward, relPos) - camera.nearClipPlane);
frustumPlaneEquations[5] = new Vector4(-forward.x, -forward.y, -forward.z, Vector3.Dot(forward, relPos) + camera.farClipPlane);
}
void ConfigureStereoMatrices()

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


}
m_LightLoop.UpdateCullingParameters(ref cullingParams);
hdCamera.UpdateStereoDependentState(m_FrameSettings, hdCamera.camera, ref cullingParams);
hdCamera.UpdateStereoDependentState(m_FrameSettings, ref cullingParams);
#if UNITY_EDITOR
// emit scene view UI

正在加载...
取消
保存