Add an Orthogonal Projection option to the Camera Gem (#2414)

* Add an Orthogonal Projection option to the Camera Gem

This adds a check-box to opt into an ortho projection along with a half-width parameter to adjust the size of the visible area. Includes some light tweaks to ensure debug rendering looks OK and that we generate a correct camera state for these non-perspective views.

Known issue: while in "Be this camera" mode in the Editor using an ortho projection manipulators aren't working correctly. This appears to be a downstream issue with CameraState consumers not actually checking the ortho flag.

Signed-off-by: nvsickle <nvsickle@amazon.com>

* Fix some typos

Signed-off-by: nvsickle <nvsickle@amazon.com>

* Account for reversed depth buffer

Signed-off-by: nvsickle <nvsickle@amazon.com>

* Clarify depth reversal for MakeOrthographicMatrixRH

Signed-off-by: nvsickle <nvsickle@amazon.com>
This commit is contained in:
Nicholas Van Sickle
2021-07-26 13:58:50 -07:00
committed by GitHub
parent e81f59d1e1
commit 7f84a4318c
12 changed files with 232 additions and 33 deletions
@@ -185,6 +185,15 @@ namespace AZ
return m_componentConfig.m_depthFar * tanf(m_componentConfig.m_fovY / 2) * 2;
}
bool CameraComponent::IsOrthographic()
{
return false;
}
float CameraComponent::GetOrthographicHalfWidth()
{
return 0.0f;
}
void CameraComponent::SetFovDegrees(float fov)
{
@@ -226,6 +235,16 @@ namespace AZ
UpdateViewToClipMatrix();
}
void CameraComponent::SetOrthographic(bool orthographic)
{
AZ_Assert(!orthographic, "DebugCamera does not support orthographic projection");
}
void CameraComponent::SetOrthographicHalfWidth([[maybe_unused]] float halfWidth)
{
AZ_Assert(false, "DebugCamera does not support orthographic projection");
}
void CameraComponent::MakeActiveView()
{
// do nothing