本文整理汇总了C++中Spectrum::GetSampleValueAtWavelengthIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Spectrum::GetSampleValueAtWavelengthIndex方法的具体用法?C++ Spectrum::GetSampleValueAtWavelengthIndex怎么用?C++ Spectrum::GetSampleValueAtWavelengthIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spectrum
的用法示例。
在下文中一共展示了Spectrum::GetSampleValueAtWavelengthIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Li
Spectrum SingleScatteringFluorescenceRWLIntegrator::Li(const Scene *scene,
const Renderer *renderer, const RayDifferential &ray,
const Sample *sample, RNG &rng, Spectrum *T, MemoryArena &arena) const {
VolumeRegion *vr = scene->volumeRegion;
float t0, t1;
if (!vr || !vr->IntersectP(ray, &t0, &t1) || (t1-t0) == 0.f) {
*T = 1.f;
return 0.f;
}
// Do single scattering volume integration in _vr_
Spectrum Lv(0.);
// Prepare for volume integration stepping
int nSamples = Ceil2Int((t1-t0) / stepSize);
float step = (t1 - t0) / nSamples;
Spectrum Tr(1.f);
Point p = ray(t0), pPrev;
Vector w = -ray.d;
t0 += sample->oneD[scatterSampleOffset][0] * step;
// Compute sample patterns for single scattering samples
float *lightNum = arena.Alloc<float>(nSamples);
LDShuffleScrambled1D(1, nSamples, lightNum, rng);
float *lightComp = arena.Alloc<float>(nSamples);
LDShuffleScrambled1D(1, nSamples, lightComp, rng);
float *lightPos = arena.Alloc<float>(2*nSamples);
LDShuffleScrambled2D(1, nSamples, lightPos, rng);
uint32_t sampOffset = 0;
for (int i = 0; i < nSamples; ++i, t0 += step) {
// Advance to sample at _t0_ and update _T_
pPrev = p;
p = ray(t0);
Ray tauRay(pPrev, p - pPrev, 0.f, 1.f, ray.time, ray.depth);
Spectrum stepTau = vr->tau(tauRay, 0.5f * stepSize, rng.RandomFloat());
Tr *= Exp(-stepTau);
// Possibly terminate ray marching if transmittance is small
if (Tr.y() < 1e-3) {
const float continueProb = .5f;
if (rng.RandomFloat() > continueProb) {
Tr = 0.f;
break;
}
Tr /= continueProb;
}
// Compute fluorescence emission
Spectrum sigma = vr->Mu(p, w, ray.time);
if (!sigma.IsBlack() && scene->lights.size() > 0) {
int nLights = scene->lights.size();
int ln = min(Floor2Int(lightNum[sampOffset] * nLights),
nLights-1);
Light *light = scene->lights[ln];
// Add contribution of _light_ due to the in-scattering at _p_
float pdf;
VisibilityTester vis;
Vector wo;
LightSample ls(lightComp[sampOffset], lightPos[2*sampOffset],
lightPos[2*sampOffset+1]);
Spectrum L = light->Sample_L(p, 0.f, ls, ray.time, &wo, &pdf, &vis);
if (!L.IsBlack() && pdf > 0.f && vis.Unoccluded(scene)) {
Spectrum Ld = L * vis.Transmittance(scene, renderer, NULL, rng,
arena);
int lambdaExcIndex = light->GetLaserWavelengthIndex();
float Lpower = Ld.GetLaserEmissionPower(lambdaExcIndex);
float yield = vr->Yeild(Point());
Spectrum fEx = vr->fEx(Point());
Spectrum fEm = vr->fEm(Point());
float scale = fEx.GetSampleValueAtWavelengthIndex(lambdaExcIndex);
Lv += Lpower * Tr * sigma * vr->p(p, w, -wo, ray.time) *
scale * fEm * yield * float(nLights) / pdf;
}
}
++sampOffset;
}
*T = Tr;
return Lv * step;
}