Skip to content

Commit e3615bd

Browse files
Set GL projection matrix based on NDC min z rather than always for GL device
GL may also use [0, 1] NDC if appropriate extension is enabled
1 parent 8c83292 commit e3615bd

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

SampleBase/src/SampleBase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2023 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -126,7 +126,7 @@ float4x4 SampleBase::GetAdjustedProjectionMatrix(float FOV, float NearPlane, flo
126126
float4x4 Proj;
127127
Proj._11 = XScale;
128128
Proj._22 = YScale;
129-
Proj.SetNearFarClipPlanes(NearPlane, FarPlane, m_pDevice->GetDeviceInfo().IsGLDevice());
129+
Proj.SetNearFarClipPlanes(NearPlane, FarPlane, m_pDevice->GetDeviceInfo().NDC.MinZ == -1);
130130
return Proj;
131131
}
132132

Samples/Shadows/src/ShadowsSample.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -668,7 +668,7 @@ void ShadowsSample::WindowResize(Uint32 Width, Uint32 Height)
668668
float FarPlane = 250.f;
669669
float AspectRatio = static_cast<float>(Width) / static_cast<float>(Height);
670670
m_Camera.SetProjAttribs(NearPlane, FarPlane, AspectRatio, PI_F / 4.f,
671-
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().IsGLDevice());
671+
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().NDC.MinZ == -1);
672672
}
673673

674674
} // namespace Diligent

Tutorials/Tutorial21_RayTracing/src/Tutorial21_RayTracing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -852,7 +852,7 @@ void Tutorial21_RayTracing::WindowResize(Uint32 Width, Uint32 Height)
852852
// Update projection matrix.
853853
float AspectRatio = static_cast<float>(Width) / static_cast<float>(Height);
854854
m_Camera.SetProjAttribs(m_Constants.ClipPlanes.x, m_Constants.ClipPlanes.y, AspectRatio, PI_F / 4.f,
855-
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().IsGLDevice());
855+
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().NDC.MinZ == -1);
856856

857857
// Check if the image needs to be recreated.
858858
if (m_pColorRT != nullptr &&

Tutorials/Tutorial22_HybridRendering/src/Tutorial22_HybridRendering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -978,7 +978,7 @@ void Tutorial22_HybridRendering::WindowResize(Uint32 Width, Uint32 Height)
978978
// Update projection matrix.
979979
float AspectRatio = static_cast<float>(Width) / static_cast<float>(Height);
980980
m_Camera.SetProjAttribs(0.1f, 100.f, AspectRatio, PI_F / 4.f,
981-
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().IsGLDevice());
981+
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().NDC.MinZ == -1);
982982

983983
// Check if the image needs to be recreated.
984984
if (m_GBuffer.Color != nullptr &&

Tutorials/Tutorial23_CommandQueues/src/Tutorial23_CommandQueues.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -643,7 +643,7 @@ void Tutorial23_CommandQueues::WindowResize(Uint32 Width, Uint32 Height)
643643
// Update projection matrix.
644644
float AspectRatio = static_cast<float>(Width) / static_cast<float>(Height);
645645
m_Camera.SetProjAttribs(1.f, 1000.f, AspectRatio, PI_F / 4.f,
646-
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().IsGLDevice());
646+
m_pSwapChain->GetDesc().PreTransform, m_pDevice->GetDeviceInfo().NDC.MinZ == -1);
647647

648648
// Check if the image needs to be recreated.
649649
if (m_GBuffer.Color != nullptr &&

0 commit comments

Comments
 (0)