本文整理汇总了C++中PathSampleGenerator::uniformGenerator方法的典型用法代码示例。如果您正苦于以下问题:C++ PathSampleGenerator::uniformGenerator方法的具体用法?C++ PathSampleGenerator::uniformGenerator怎么用?C++ PathSampleGenerator::uniformGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathSampleGenerator
的用法示例。
在下文中一共展示了PathSampleGenerator::uniformGenerator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transmittance
Vec3f VdbGrid::transmittance(PathSampleGenerator &sampler, Vec3f p, Vec3f w, float t0, float t1, Vec3f sigmaT) const
{
auto accessor = _grid->getConstAccessor();
if (_integrationMethod == IntegrationMethod::ExactNearest) {
VdbRaymarcher<openvdb::FloatGrid::TreeType, 3> dda;
float integral = 0.0f;
dda.march(DdaRay(p + 0.5f, w), t0, t1, accessor, [&](openvdb::Coord voxel, float ta, float tb) {
integral += accessor.getValue(voxel)*(tb - ta);
return false;
});
return std::exp(-integral*sigmaT);
} else if (_integrationMethod == IntegrationMethod::ExactLinear) {
VdbRaymarcher<openvdb::FloatGrid::TreeType, 3> dda;
float integral = 0.0f;
float fa = gridAt(accessor, p + w*t0);
dda.march(DdaRay(p, w), t0, t1, accessor, [&](openvdb::Coord /*voxel*/, float ta, float tb) {
float fb = gridAt(accessor, p + w*tb);
integral += (fa + fb)*0.5f*(tb - ta);
fa = fb;
return false;
});
return std::exp(-integral*sigmaT);
} else if (_integrationMethod == IntegrationMethod::ResidualRatio) {
VdbRaymarcher<Vec2fGrid::TreeType, 3> dda;
float scale = _supergridSubsample;
float invScale = 1.0f/scale;
sigmaT *= scale;
float sigmaTc = sigmaT.max();
auto superAccessor = _superGrid->getConstAccessor();
UniformSampler &generator = sampler.uniformGenerator();
float controlIntegral = 0.0f;
Vec3f Tr(1.0f);
dda.march(DdaRay(p*invScale + 0.5f, w), t0*invScale, t1*invScale, superAccessor, [&](openvdb::Coord voxel, float ta, float tb) {
openvdb::Vec2s v = superAccessor.getValue(voxel);
float muC = v.x();
float muR = v.y();
muR *= sigmaTc;
controlIntegral += muC*(tb - ta);
while (true) {
ta -= BitManip::normalizedLog(generator.nextI())/muR;
if (ta >= tb)
break;
Tr *= 1.0f - sigmaT*((gridAt(accessor, p + w*ta*scale) - muC)/muR);
}
return false;
});
return std::exp(-controlIntegral*sigmaT)*Tr;
} else {
float ta = t0;
float fa = gridAt(accessor, p + w*t0);
float integral = 0.0f;
float dT = sampler.next1D()*_stepSize;
do {
float tb = min(ta + dT, t1);
float fb = gridAt(accessor, p + w*tb);
integral += (fa + fb)*0.5f*(tb - ta);
ta = tb;
fa = fb;
dT = _stepSize;
} while (ta < t1);
return std::exp(-integral*sigmaT);
}
}