本文整理汇总了C++中Sampler::draw1D方法的典型用法代码示例。如果您正苦于以下问题:C++ Sampler::draw1D方法的具体用法?C++ Sampler::draw1D怎么用?C++ Sampler::draw1D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sampler
的用法示例。
在下文中一共展示了Sampler::draw1D方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sampleRandomly
/*!
\details
No detailed.
*/
SampledWavelengths WavelengthSampler::sampleRandomly(
Sampler& sampler,
PathState& path_state) noexcept
{
using zisc::cast;
constexpr uint sample_size = SampledWavelengths::size();
constexpr Float inverse_probability = cast<Float>(CoreConfig::spectraSize()) /
cast<Float>(sample_size);
std::array<uint16, sample_size> wavelengths;
for (uint i = 0; i < sample_size; ++i) {
const Float offset = sampler.draw1D(path_state);
path_state.setDimension(path_state.dimension() + 1);
const Float position = cast<Float>(CoreConfig::spectraSize()) * offset;
const uint index = cast<uint>(position);
const uint16 wavelength = getWavelength(index);
wavelengths[i] = wavelength;
}
std::sort(wavelengths.begin(), wavelengths.end());
SampledWavelengths sampled_wavelengths;
for (uint i = 0; i < sample_size; ++i)
sampled_wavelengths.set(i, wavelengths[i], inverse_probability);
sampled_wavelengths.selectPrimaryWavelength(sampler, path_state);
return sampled_wavelengths;
}
示例2: sampleInfo
/*!
*/
inline
LightSourceInfo UniformLightSourceSampler::sampleInfo(
Sampler& sampler,
const PathState& path_state) const noexcept
{
const auto& light_source_list = lightSourceList();
const Float k = zisc::cast<Float>(light_source_list.size());
const Float r = sampler.draw1D(path_state);
const uint light_number = zisc::cast<uint>(k * r);
return LightSourceInfo{light_source_list[light_number], weightPerLight()};
}
示例3: sampleRegularly
/*!
\details
No detailed.
*/
SampledWavelengths WavelengthSampler::sampleRegularly(
Sampler& sampler,
PathState& path_state) noexcept
{
using zisc::cast;
constexpr uint sample_size = SampledWavelengths::size();
constexpr Float interval = cast<Float>(CoreConfig::spectraSize()) /
cast<Float>(sample_size);
constexpr Float inverse_probability = interval;
SampledWavelengths sampled_wavelengths;
const Float offset = sampler.draw1D(path_state);
for (uint i = 0; i < sample_size; ++i) {
path_state.setDimension(path_state.dimension() + 1);
const uint index = cast<uint>(interval * (cast<Float>(i) + offset));
const uint16 wavelength = getWavelength(index);
sampled_wavelengths.set(i, wavelength, inverse_probability);
}
sampled_wavelengths.selectPrimaryWavelength(sampler, path_state);
return sampled_wavelengths;
}