MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/HBAOPlus / Init

Method Init

src/ProjectionMatrixInfo.cpp:15–50  ·  view source on GitHub ↗

--------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

13
14//--------------------------------------------------------------------------------
15GFSDK_SSAO_Status GFSDK::SSAO::ProjectionMatrixInfo::Init(const GFSDK_SSAO_Matrix& ProjectionMatrix, APIConventions API)
16{
17 if (!IsValid(ProjectionMatrix))
18 {
19 return GFSDK_SSAO_INVALID_PROJECTION_MATRIX;
20 }
21
22 MatrixView m(ProjectionMatrix);
23
24 // In matrices generated with D3DXMatrixPerspectiveFovRH
25 // A = zf/(zn-zf)
26 // B = zn*zf/(zn-zf)
27 // C = -1
28 float A = m(2,2);
29 float B = m(3,2);
30 float C = m(2,3);
31
32 // In matrices generated with D3DXMatrixPerspectiveFovLH
33 // A = -zf/(zn-zf)
34 // B = zn*zf/(zn-zf)
35 // C = 1
36 if (C == 1.f)
37 {
38 A = -A;
39 }
40
41 // Rely on INFs to be generated in case of any divisions by zero
42 m_ZNear = (API == API_GL) ? (B / (A - 1.f)) : (B / A);
43 m_ZFar = B / (A + 1.f);
44
45 // Some matrices may use negative m00 or m11 terms to flip X/Y axises
46 m_TanHalfFovX = 1.f / fabs(m(0,0));
47 m_TanHalfFovY = 1.f / fabs(m(1,1));
48
49 return GFSDK_SSAO_OK;
50}
51
52//--------------------------------------------------------------------------------
53bool GFSDK::SSAO::ProjectionMatrixInfo::IsValid(const GFSDK_SSAO_Matrix& ProjectionMatrix)

Callers

nothing calls this directly

Calls 1

mFunction · 0.85

Tested by

no test coverage detected