コード例 #1
0
ファイル: stratified.cpp プロジェクト: marwan-abdellah/Wisp
    StratifiedSampler(const ParamSet& paramSet)
    {
        size_t desiredSampleCount = (size_t) paramSet.getInteger("sampleCount", 1);

        size_t i = 1;
        while (i * i < desiredSampleCount)
            ++i;

        m_resolution = i;
        m_sampleCount = m_resolution * m_resolution;

        if (m_sampleCount != desiredSampleCount)
            std::cout << "Sample count should be a perfect square -- rounding to "
                      << m_sampleCount << std::endl;

        m_depth = paramSet.getInteger("depth", 3);
        m_permutations1D = new size_t*[m_depth];
        m_permutations2D = new size_t*[m_depth];

        for (int i = 0; i < m_depth; ++i)
        {
            m_permutations1D[i] = new size_t[m_sampleCount];
            m_permutations2D[i] = new size_t[m_sampleCount];
        }

        m_invResolution = 1.0f / (float)m_resolution;
        m_invResolutionSquare = 1.0f / (float) m_sampleCount;
        m_random = new Random();
        m_sampleIndex = 0;
    }