MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / ConvertToH4

Function ConvertToH4

SampleFramework12/v1.00/Graphics/SH.cpp:90–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90H4 ConvertToH4(const SH9& sh)
91{
92 const float rt2 = sqrt(2.0f);
93 const float rt32 = sqrt(3.0f / 2.0f);
94 const float rt52 = sqrt(5.0f / 2.0f);
95 const float rt152 = sqrt(15.0f / 2.0f);
96 const float convMatrix[4][9] =
97 {
98 { 1.0f / rt2, 0, 0.5f * rt32, 0, 0, 0, 0, 0, 0 },
99 { 0, 1.0f / rt2, 0, 0, 0, (3.0f / 8.0f) * rt52, 0, 0, 0 },
100 { 0, 0, 1.0f / (2.0f * rt2), 0, 0, 0, 0.25f * rt152, 0, 0 },
101 { 0, 0, 0, 1.0f / rt2, 0, 0, 0, (3.0f / 8.0f) * rt52, 0 }
102 };
103
104 H4 hBasis;
105
106 for(uint64 row = 0; row < 4; ++row)
107 {
108 hBasis.Coefficients[row] = 0.0f;
109
110 for(uint64 col = 0; col < 9; ++col)
111 hBasis.Coefficients[row] += convMatrix[row][col] * sh.Coefficients[col];
112 }
113
114 return hBasis;
115}
116
117SH9Color ProjectCubemapToSH(const Texture& texture)
118{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected