MCPcopy Create free account
hub / github.com/LuxCoreRender/LuxCore / Sample

Method Sample

src/slg/core/sphericalfunction/sphericalfunction.cpp:83–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83Spectrum SampleableSphericalFunction::Sample(
84 const float u1, const float u2, Vector *w, float *pdf) const {
85 // Find floating-point $(u,v)$ sample coordinates
86 float uv[2];
87 uvDistrib->SampleContinuous(u1, u2, uv, pdf);
88 if (*pdf == 0.f)
89 return Spectrum();
90
91 // Convert sample point to direction on the unit sphere
92 const float theta = uv[1] * M_PI;
93 const float phi = uv[0] * 2.f * M_PI;
94 const float costheta = cosf(theta), sintheta = sinf(theta);
95 *w = SphericalDirection(sintheta, costheta, phi);
96
97 // Compute PDF for sampled direction
98 *pdf /= 2.f * M_PI * M_PI * sintheta;
99
100 // Return value for direction
101 return Evaluate(phi, theta) / *pdf;
102}
103
104float SampleableSphericalFunction::Pdf(const Vector &w) const {
105 const float theta = SphericalTheta(w);

Callers 9

GenerateRayMethod · 0.45
SampleLensMethod · 0.45
ClampRayMethod · 0.45
GetSamplePositionMethod · 0.45
SampleLensMethod · 0.45
GetPDFMethod · 0.45
GetSamplePositionMethod · 0.45
SampleLensMethod · 0.45
GenerateRayMethod · 0.45

Calls 2

SphericalDirectionFunction · 0.85
SampleContinuousMethod · 0.45

Tested by 4

ClampRayMethod · 0.36
GetSamplePositionMethod · 0.36
SampleLensMethod · 0.36
GetPDFMethod · 0.36