MCPcopy Create free account
hub / github.com/TheRealMJP/SHforHLSL / SolveProjection

Function SolveProjection

SHTest/SampleFramework12/v1.04/Graphics/SG.cpp:214–234  ·  view source on GitHub ↗

Do a projection of the colors onto the SG's

Source from the content-addressed store, hash-verified

212
213// Do a projection of the colors onto the SG's
214static void SolveProjection(SGSolveParams& params)
215{
216 Assert_(params.SampleDirs != nullptr);
217 Assert_(params.SampleValues != nullptr);
218
219 // Project color samples onto the SGs
220 for(uint32 i = 0; i < params.NumSamples; ++i)
221 ProjectOntoSGs(params.SampleDirs[i], params.SampleValues[i], params.OutSGs, params.NumSGs);
222
223 // Weight the samples by the monte carlo factor for uniformly sampling the sphere/hemisphere
224 float monteCarloFactor = ((2.0f * Pi) / params.NumSamples);
225 if(params.Distribution == SGDistribution::Spherical)
226 monteCarloFactor *= 2.0f;
227
228 // Fudge factor to help correct the intensity from our bad projection algorithim
229 if(params.Distribution == SGDistribution::Spherical && params.NumSGs == 9)
230 monteCarloFactor *= Pi / 2.46373701f;
231
232 for(uint32 i = 0; i < params.NumSGs; ++i)
233 params.OutSGs[i].Amplitude *= monteCarloFactor;
234}
235
236// Solve the set of spherical gaussians based on input set of data
237void SolveSGs(SGSolveParams& params)

Callers 1

SolveSGsFunction · 0.85

Calls 1

ProjectOntoSGsFunction · 0.85

Tested by

no test coverage detected