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

Function ProjectOntoSGs

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

Project sample onto SGs

Source from the content-addressed store, hash-verified

189
190// Project sample onto SGs
191void 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
214static void SolveProjection(SGSolveParams& params)

Callers 1

SolveProjectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected