本文整理汇总了C++中VisibilityTester::T方法的典型用法代码示例。如果您正苦于以下问题:C++ VisibilityTester::T方法的具体用法?C++ VisibilityTester::T怎么用?C++ VisibilityTester::T使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisibilityTester
的用法示例。
在下文中一共展示了VisibilityTester::T方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConnectBDPT
Spectrum ConnectBDPT(const Scene &scene, Vertex *lightSubpath,
Vertex *cameraSubpath, int s, int t,
const Distribution1D &lightDistr, const Camera &camera,
Sampler &sampler, Point2f *rasterPos, Float *misWeight) {
Spectrum weight(0.f);
// Ignore invalid connections related to infinite area lights
if (t > 1 && s != 0 && cameraSubpath[t - 1].type == VertexType::Light)
return Spectrum(0.f);
// Perform connection and write contribution to _weight_
Vertex sampled;
if (s == 0) {
// Interpret the camera subpath as a complete path
const Vertex &pt = cameraSubpath[t - 1];
if (pt.IsLight()) {
const Vertex &ptMinus = cameraSubpath[t - 2];
weight = pt.Le(scene, ptMinus) * pt.weight;
}
} else if (t == 1) {
// Sample a point on the camera and connect it to the light subpath
const Vertex &qs = lightSubpath[s - 1];
if (qs.IsConnectible()) {
VisibilityTester vis;
Vector3f wi;
Float pdf;
Spectrum cameraWeight =
camera.Sample_We(qs.GetInteraction(), sampler.Get2D(), &wi,
&pdf, rasterPos, &vis);
if (pdf > 0 && !cameraWeight.IsBlack()) {
// Initialize dynamically sampled vertex and _weight_
sampled = Vertex(VertexType::Camera,
EndpointInteraction(vis.P1(), &camera),
cameraWeight);
weight = qs.weight * qs.f(sampled) * vis.T(scene, sampler) *
sampled.weight;
if (qs.IsOnSurface())
weight *= AbsDot(wi, qs.GetShadingNormal());
}
}
} else if (s == 1) {
// Sample a point on a light and connect it to the camera subpath
const Vertex &pt = cameraSubpath[t - 1];
if (pt.IsConnectible()) {
Float lightPdf;
VisibilityTester vis;
Vector3f wi;
Float pdf;
int lightNum =
lightDistr.SampleDiscrete(sampler.Get1D(), &lightPdf);
const std::shared_ptr<Light> &light = scene.lights[lightNum];
Spectrum lightWeight = light->Sample_L(
pt.GetInteraction(), sampler.Get2D(), &wi, &pdf, &vis);
if (pdf > 0 && !lightWeight.IsBlack()) {
sampled = Vertex(VertexType::Light,
EndpointInteraction(vis.P1(), light.get()),
lightWeight / (pdf * lightPdf));
sampled.pdfFwd = sampled.PdfLightOrigin(scene, pt, lightDistr);
weight = pt.weight * pt.f(sampled) * vis.T(scene, sampler) *
sampled.weight;
if (pt.IsOnSurface())
weight *= AbsDot(wi, pt.GetShadingNormal());
}
}
} else {
// Handle all other cases
const Vertex &qs = lightSubpath[s - 1], &pt = cameraSubpath[t - 1];
if (qs.IsConnectible() && pt.IsConnectible()) {
weight = qs.weight * qs.f(pt) *
GeometryTerm(scene, sampler, qs, pt) * pt.f(qs) *
pt.weight;
}
}
// Compute MIS weight for connection strategy
*misWeight =
weight.IsBlack() ? 0.f : MISWeight(scene, lightSubpath, cameraSubpath,
sampled, s, t, lightDistr);
return weight;
}