Project sample onto SGs
| 169 | |
| 170 | // Project sample onto SGs |
| 171 | void ProjectOntoSGs(const Float3& dir, const Float3& color, SG* outSGs, uint64 numSGs) |
| 172 | { |
| 173 | for(uint64 i = 0; i < numSGs; ++i) |
| 174 | { |
| 175 | SG sg1; |
| 176 | SG sg2; |
| 177 | sg1.Amplitude = outSGs[i].Amplitude; |
| 178 | sg1.Axis = outSGs[i].Axis; |
| 179 | sg1.Sharpness = outSGs[i].Sharpness; |
| 180 | sg2.Amplitude = color; |
| 181 | sg2.Axis = Float3::Normalize(dir); |
| 182 | |
| 183 | if(Float3::Dot(dir, sg1.Axis) > 0.0f) |
| 184 | { |
| 185 | float dot = Float3::Dot(sg1.Axis, sg2.Axis); |
| 186 | float factor = (dot - 1.0f) * sg1.Sharpness; |
| 187 | float wgt = exp(factor); |
| 188 | outSGs[i].Amplitude += sg2.Amplitude * wgt; |
| 189 | Assert_(outSGs[i].Amplitude.x >= 0.0f); |
| 190 | Assert_(outSGs[i].Amplitude.y >= 0.0f); |
| 191 | Assert_(outSGs[i].Amplitude.z >= 0.0f); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // Do a projection of the colors onto the SG's |
| 197 | static void SolveProjection(SGSolveParam& params) |
no test coverage detected