本文整理汇总了C++中Sample::AddContribution方法的典型用法代码示例。如果您正苦于以下问题:C++ Sample::AddContribution方法的具体用法?C++ Sample::AddContribution怎么用?C++ Sample::AddContribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sample
的用法示例。
在下文中一共展示了Sample::AddContribution方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Li
u_int DistributedPath::Li(const Scene &scene, const Sample &sample) const
{
u_int nrContribs = 0;
float zdepth = 0.f;
Ray ray;
float xi, yi;
float rayWeight = sample.camera->GenerateRay(scene, sample, &ray, &xi, &yi);
vector<SWCSpectrum> L(scene.lightGroups.size(), SWCSpectrum(0.f));
float alpha = 1.f;
LiInternal(scene, sample, NULL, false, ray, L, &alpha, &zdepth, 0, true,
nrContribs);
for (u_int i = 0; i < L.size(); ++i)
sample.AddContribution(xi, yi,
XYZColor(sample.swl, L[i]) * rayWeight, alpha, zdepth,
0.f, bufferId, i);
return nrContribs;
}
示例2: TraceEyePath
//.........这里部分代码省略.........
SWCSpectrum Le(pathThroughput);
if (isect.Le(sample, ray, &ibsdf, NULL, NULL, &Le)) {
L[isect.arealight->group] += Le;
V[isect.arealight->group] += Le.Filter(sw) * VContrib;
}
}
const Point &p = bsdf->dgShading.p;
const Normal &n = bsdf->dgShading.nn;
// Estimate direct lighting
if (renderer->sppmi->directLightSampling && (nLights > 0)) {
for (u_int i = 0; i < lightGroupCount; ++i) {
Ld[i] = 0.f;
Vd[i] = 0.f;
}
renderer->sppmi->hints.SampleLights(scene, sample, p, n,
wo, bsdf, pathLength, pathThroughput, Ld, &Vd);
for (u_int i = 0; i < lightGroupCount; ++i) {
L[i] += Ld[i];
V[i] += Vd[i] * VContrib;
}
}
// Choose between storing or bouncing the hitpoint on the surface
bool const has_store_component = bsdf->NumComponents(store_component) > 0;
bool const has_bounce_component = bsdf->NumComponents(bounce_component) > 0;
float pdf_event;
bool store;
if (has_store_component && has_bounce_component)
{
// There is both bounce and store component, we choose with a
// random number
// TODO: do this by importance
store = data[4] < .5f;
pdf_event = 0.5;
}
else
{
// If there is only bounce/store component, we bounce/store
// accordingly
store = has_store_component;
pdf_event = 1.f;
}
if(store)
{
hp->SetSurface();
hpep->pathThroughput = pathThroughput * rayWeight / pdf_event * invPixelPdf;
hpep->wo = wo;
hpep->bsdf = bsdf;
hpep->single = sw.single;
sample.arena.Commit();
break;
}
// Sample BSDF to get new path direction
Vector wi;
float pdf;
BxDFType flags;
SWCSpectrum f;
if (pathLength == maxDepth || !bsdf->SampleF(sw, wo, &wi,
data[1], data[2], data[3], &f, &pdf, bounce_component, &flags,
NULL, true)) {
hp->SetConstant();
break;
}
if (flags != (BSDF_TRANSMISSION | BSDF_SPECULAR) ||
!(bsdf->Pdf(sw, wi, wo, BxDFType(BSDF_TRANSMISSION | BSDF_SPECULAR)) > 0.f))
{
++vertexIndex;
specularBounce = (flags & BSDF_SPECULAR) != 0;
}
pathThroughput *= f / pdf_event;
if (pathThroughput.Black()) {
hp->SetConstant();
break;
}
ray = Ray(p, wi);
ray.time = sample.realTime;
volume = bsdf->GetVolume(wi);
}
for(unsigned int i = 0; i < lightGroupCount; ++i)
{
if (!L[i].Black())
V[i] /= L[i].Filter(sw);
sample.AddContribution(hp->imageX, hp->imageY,
XYZColor(sw, L[i]) * rayWeight, hp->eyePass.alpha, hp->eyePass.distance,
0, renderer->sppmi->bufferEyeId, i);
}
}