当前位置: 首页>>代码示例>>C++>>正文


C++ Sampler::draw1D方法代码示例

本文整理汇总了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;
}
开发者ID:byzin,项目名称:Nanairo,代码行数:30,代码来源:wavelength_sampler.cpp

示例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()};
}
开发者ID:byzin,项目名称:Nanairo,代码行数:13,代码来源:uniform_light_source_sampler.cpp

示例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;
}
开发者ID:byzin,项目名称:Nanairo,代码行数:25,代码来源:wavelength_sampler.cpp


注:本文中的Sampler::draw1D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。