| 88 | } |
| 89 | |
| 90 | H4 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 | |
| 117 | SH9Color ProjectCubemapToSH(const Texture& texture) |
| 118 | { |
nothing calls this directly
no outgoing calls
no test coverage detected