Project sample onto SGs
| 189 | |
| 190 | // Project sample onto SGs |
| 191 | void ProjectOntoSGs(const Float3& dir, const Float3& color, SG* outSGs, uint64 numSGs) |
| 192 | { |
| 193 | for(uint64 i = 0; i < numSGs; ++i) |
| 194 | { |
| 195 | SG sg1; |
| 196 | SG sg2; |
| 197 | sg1.Amplitude = outSGs[i].Amplitude; |
| 198 | sg1.Axis = outSGs[i].Axis; |
| 199 | sg1.Sharpness = outSGs[i].Sharpness; |
| 200 | sg2.Amplitude = color; |
| 201 | sg2.Axis = Float3::Normalize(dir); |
| 202 | |
| 203 | if(Float3::Dot(dir, sg1.Axis) > 0.0f) |
| 204 | { |
| 205 | float dot = Float3::Dot(sg1.Axis, sg2.Axis); |
| 206 | float factor = (dot - 1.0f) * sg1.Sharpness; |
| 207 | float wgt = exp(factor); |
| 208 | outSGs[i].Amplitude += sg2.Amplitude * wgt; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // Do a projection of the colors onto the SG's |
| 214 | static void SolveProjection(SGSolveParams& params) |