MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / ProjectOntoSGs

Function ProjectOntoSGs

BakingLab/SG.cpp:171–194  ·  view source on GitHub ↗

Project sample onto SGs

Source from the content-addressed store, hash-verified

169
170// Project sample onto SGs
171void 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
197static void SolveProjection(SGSolveParam& params)

Callers 2

SolveProjectionFunction · 0.85
AddSampleMethod · 0.85

Calls 1

expFunction · 0.85

Tested by

no test coverage detected