本文整理汇总了C++中Distribution1D::Sample方法的典型用法代码示例。如果您正苦于以下问题:C++ Distribution1D::Sample方法的具体用法?C++ Distribution1D::Sample怎么用?C++ Distribution1D::Sample使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Distribution1D
的用法示例。
在下文中一共展示了Distribution1D::Sample方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Sample_L
Spectrum InfiniteAreaLightIS::Sample_L(const Point &p, float u1,
float u2, Vector *wi, float *pdf,
VisibilityTester *visibility) const {
// Find floating-point $(u,v)$ sample coordinates
float pdfs[2];
float fu = uDistrib->Sample(u1, &pdfs[0]);
int u = Clamp(Float2Int(fu), 0, uDistrib->count-1);
float fv = vDistribs[u]->Sample(u2, &pdfs[1]);
if (pdfs[0] == 0.f || pdfs[1] == 0.f) {
*pdf = 0.f;
return Spectrum(0.f);
}
// Convert sample point to direction on the unit sphere
float theta = fv * vDistribs[u]->invCount * M_PI;
float phi = fu * uDistrib->invCount * 2.f * M_PI;
float costheta = cos(theta), sintheta = sin(theta);
if (sintheta == 0.f) return 0.f;
float sinphi = sin(phi), cosphi = cos(phi);
*wi = LightToWorld(Vector(sintheta * cosphi, sintheta * sinphi,
costheta));
// Compute PDF for sampled direction
*pdf = (pdfs[0] * pdfs[1]) / (2. * M_PI * M_PI * sintheta);
// Return radiance value for direction
visibility->SetRay(p, *wi);
return Lbase * radianceMap->Lookup(fu * uDistrib->invCount,
fv * vDistribs[u]->invCount);
}