本文整理汇总了C++中VisibilityTester::Visibility方法的典型用法代码示例。如果您正苦于以下问题:C++ VisibilityTester::Visibility方法的具体用法?C++ VisibilityTester::Visibility怎么用?C++ VisibilityTester::Visibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisibilityTester
的用法示例。
在下文中一共展示了VisibilityTester::Visibility方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EstimateDirect
Spectrum EstimateDirect(const Scene *scene, const Renderer *renderer,
MemoryArena &arena, const Light *light, const Point &p,
const Normal &n, const Vector &wo, float rayEpsilon, float time,
const BSDF *bsdf, RNG &rng, const LightSample &lightSample,
const BSDFSample &bsdfSample, BxDFType flags) {
Spectrum Ld(0.);
// Sample light source with multiple importance sampling
Vector wi;
float lightPdf, bsdfPdf;
VisibilityTester visibility;
Spectrum Li = light->Sample_L(p, rayEpsilon, lightSample, time,
&wi, &lightPdf, &visibility);
if (lightPdf > 0. && !Li.IsBlack()) {
Spectrum f = bsdf->f(wo, wi, flags);
float pVis = 0;
if (!f.IsBlack() && (pVis = visibility.Visibility(scene)) != 0.) {
// Add light's contribution to reflected radiance
Li *= pVis * visibility.Transmittance(scene, renderer, NULL, rng, arena);
if (light->IsDeltaLight())
Ld += f * Li * (AbsDot(wi, n) / lightPdf);
else {
bsdfPdf = bsdf->Pdf(wo, wi, flags);
float weight = PowerHeuristic(1, lightPdf, 1, bsdfPdf);
Ld += f * Li * (AbsDot(wi, n) * weight / lightPdf);
}
}
}
// Sample BSDF with multiple importance sampling
if (!light->IsDeltaLight()) {
BxDFType sampledType;
Spectrum f = bsdf->Sample_f(wo, &wi, bsdfSample, &bsdfPdf, flags,
&sampledType);
if (!f.IsBlack() && bsdfPdf > 0.) {
float weight = 1.f;
if (!(sampledType & BSDF_SPECULAR)) {
lightPdf = light->Pdf(p, wi);
if (lightPdf == 0.)
return Ld;
weight = PowerHeuristic(1, bsdfPdf, 1, lightPdf);
}
// Add light contribution from BSDF sampling
Intersection lightIsect;
Spectrum Li(0.f);
RayDifferential ray(p, wi, rayEpsilon, INFINITY, time);
if (scene->Intersect(ray, &lightIsect)) {
if (lightIsect.primitive->GetAreaLight() == light)
Li = lightIsect.Le(-wi);
}
else
Li = light->Le(ray);
if (!Li.IsBlack()) {
Li *= renderer->Transmittance(scene, ray, NULL, rng, arena);
Ld += f * Li * AbsDot(wi, n) * weight / bsdfPdf;
}
}
}
return Ld;
}