本文整理汇总了C++中BSDF::SampleF方法的典型用法代码示例。如果您正苦于以下问题:C++ BSDF::SampleF方法的具体用法?C++ BSDF::SampleF怎么用?C++ BSDF::SampleF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BSDF
的用法示例。
在下文中一共展示了BSDF::SampleF方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: LiInternal
//.........这里部分代码省略.........
}
}
// trace Diffuse reflection & transmission rays
if (rayDepth < diffuseReflectDepth) {
ComputeEvent(scene, sample, bsdf, wo, diffuseReflectSamples,
indirectDiffuseReflectSampleOffset, indirectDiffuseReflectComponentOffset,
diffuseReflectSampleOffset, diffuseReflectComponentOffset,
BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE),
diffuseReflectReject, diffuseReflectRejectThreshold,
L, alpha, zdepth, rayDepth, nrContribs);
}
if (rayDepth < diffuseRefractDepth) {
ComputeEvent(scene, sample, bsdf, wo, diffuseRefractSamples,
indirectDiffuseRefractSampleOffset, indirectDiffuseRefractComponentOffset,
diffuseRefractSampleOffset, diffuseRefractComponentOffset,
BxDFType(BSDF_TRANSMISSION | BSDF_DIFFUSE),
diffuseRefractReject, diffuseRefractRejectThreshold,
L, alpha, zdepth, rayDepth, nrContribs);
}
// trace Glossy reflection & transmission rays
if (rayDepth < glossyReflectDepth) {
ComputeEvent(scene, sample, bsdf, wo, glossyReflectSamples,
indirectGlossyReflectSampleOffset, indirectGlossyReflectComponentOffset,
glossyReflectSampleOffset, glossyReflectComponentOffset,
BxDFType(BSDF_REFLECTION | BSDF_GLOSSY),
glossyReflectReject, glossyReflectRejectThreshold,
L, alpha, zdepth, rayDepth, nrContribs);
}
if (rayDepth < glossyRefractDepth) {
ComputeEvent(scene, sample, bsdf, wo, glossyRefractSamples,
indirectGlossyRefractSampleOffset, indirectGlossyRefractComponentOffset,
glossyRefractSampleOffset, glossyRefractComponentOffset,
BxDFType(BSDF_TRANSMISSION | BSDF_GLOSSY),
glossyRefractReject, glossyRefractRejectThreshold,
L, alpha, zdepth, rayDepth, nrContribs);
}
// trace specular reflection & transmission rays
if (rayDepth < specularReflectDepth) {
float pdf;
Vector wi;
SWCSpectrum f;
if (bsdf->SampleF(sw, wo, &wi, .5f, .5f, .5f, &f, &pdf,
BxDFType(BSDF_REFLECTION | BSDF_SPECULAR),
NULL, NULL, true)) {
Ray rd(p, wi);
rd.time = time;
vector<SWCSpectrum> Ll(L.size(),
SWCSpectrum(0.f));
LiInternal(scene, sample, bsdf->GetVolume(wi),
bsdf->dgShading.scattered, rd, Ll,
alpha, zdepth, rayDepth + 1, true,
nrContribs);
for (u_int j = 0; j < L.size(); ++j)
L[j] += f * Ll[j];
}
}
if (rayDepth < specularRefractDepth) {
float pdf;
Vector wi;
SWCSpectrum f;
if (bsdf->SampleF(sw, wo, &wi, .5f, .5f, .5f, &f, &pdf,
BxDFType(BSDF_TRANSMISSION | BSDF_SPECULAR),
NULL, NULL, true)) {
Ray rd(p, wi);
rd.time = time;
vector<SWCSpectrum> Ll(L.size(),
SWCSpectrum(0.f));
LiInternal(scene, sample, bsdf->GetVolume(wi),
bsdf->dgShading.scattered, rd, Ll,
alpha, zdepth, rayDepth + 1, true,
nrContribs);
for (u_int j = 0; j < L.size(); ++j)
L[j] += f * Ll[j];
}
}
} else {
// Handle ray with no intersection
BSDF *ibsdf;
for (u_int i = 0; i < scene.lights.size(); ++i) {
SWCSpectrum Le(1.f);
if (scene.lights[i]->Le(scene, sample, ray, &ibsdf,
NULL, NULL, &Le)) {
L[scene.lights[i]->group] += Le;
++nrContribs;
}
}
if (rayDepth == 0)
*alpha = 0.f;
}
Lt /= spdf;
for (u_int i = 0; i < L.size(); ++i)
L[i] *= Lt;
SWCSpectrum Lv(0.f);
u_int g = scene.volumeIntegrator->Li(scene, ray, sample, &Lv, alpha);
L[g] += Lv;
}