Skip to content

Commit c06fa07

Browse files
GLTF Viewer: set camera handness
1 parent 6195a7a commit c06fa07

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Samples/Atmosphere/assets/shaders/BasicStructures.fxh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ struct CameraAttribs
118118
float4 f4Position; // Camera world position
119119
float4 f4ViewportSize; // (width, height, 1/width, 1/height)
120120

121-
float2 f2ViewportOrigin; // (min x, min y)
122121
float fNearPlaneZ;
123-
float fFarPlaneZ; // fNearPlaneZ < fFarPlaneZ
124-
122+
float fFarPlaneZ; // fNearPlaneZ < fFarPlaneZ
123+
float fHandness; // +1.0 for right-handed coordinate system, -1.0 for left-handed
124+
float Padding;
125+
125126
#ifdef __cplusplus
126127
float4x4 mViewT;
127128
float4x4 mProjT;

Samples/GLTFViewer/src/GLTFViewer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,7 @@ void GLTFViewer::Update(double CurrTime, double ElapsedTime)
13441344
const auto& SCDesc = m_pSwapChain->GetDesc();
13451345

13461346
CurrCamAttribs.f4ViewportSize = float4{static_cast<float>(SCDesc.Width), static_cast<float>(SCDesc.Height), 1.f / SCDesc.Width, 1.f / SCDesc.Height};
1347+
CurrCamAttribs.fHandness = CameraView.Determinant() > 0 ? 1.f : -1.f;
13471348
CurrCamAttribs.mViewT = CameraView.Transpose();
13481349
CurrCamAttribs.mProjT = CameraProj.Transpose();
13491350
CurrCamAttribs.mViewProjT = CameraViewProj.Transpose();

Samples/Shadows/assets/shaders/BasicStructures.fxh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ struct CameraAttribs
118118
float4 f4Position; // Camera world position
119119
float4 f4ViewportSize; // (width, height, 1/width, 1/height)
120120

121-
float2 f2ViewportOrigin; // (min x, min y)
122121
float fNearPlaneZ;
123-
float fFarPlaneZ; // fNearPlaneZ < fFarPlaneZ
124-
122+
float fFarPlaneZ; // fNearPlaneZ < fFarPlaneZ
123+
float fHandness; // +1.0 for right-handed coordinate system, -1.0 for left-handed
124+
float Padding;
125+
125126
#ifdef __cplusplus
126127
float4x4 mViewT;
127128
float4x4 mProjT;

0 commit comments

Comments
 (0)