Photon Engine
2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
RadicalInversePermutations.h
Go to the documentation of this file.
1
//#pragma once
2
//
3
//#include "Math/math_table.h"
4
//#include "Math/Random/shuffle.h"
5
//#include "Core/SampleGenerator/Detail/halton.h"
6
//
7
//#include <vector>
8
//#include <cstddef>
9
//#include <utility>
10
//#include <limits>
11
//
12
//namespace ph::halton::detail
13
//{
14
//
15
//class RadicalInversePermutations final
16
//{
17
//public:
18
// using Digit = uint16;
19
// static_assert(math::table::PRIME_TABLE[MAX_DIMENSIONS] <= std::numeric_limits<Digit>::max(),
20
// "Digit may overflow");
21
//
22
// explicit RadicalInversePermutations(std::size_t numDims);
23
//
24
// auto getPermutationForDim(std::size_t dimIndex) const
25
// -> const Digit*;
26
//
27
//private:
28
// std::vector<Digit> m_permutations;
29
//
30
// using Offset = decltype(math::table::PRIME_TABLE)::value_type;
31
// static auto PERMUTATION_OFFSETS(std::size_t dimIndex)
32
// -> Offset;
33
//
34
// static auto makePermutationOffsets()
35
// -> std::vector<Offset>;
36
//};
37
//
39
//
40
//inline RadicalInversePermutations::RadicalInversePermutations(const std::size_t numDims)
41
//{
42
// PH_ASSERT_LE(numDims, MAX_DIMENSIONS);
43
//
44
// // The offset after index <numDims - 1> is the total size of the buffer
45
// m_permutations.resize(PERMUTATION_OFFSETS(numDims));
46
//
47
// // Generate random digit permutation/mapping for each dimension
48
// for(std::size_t di = 0; di < numDims; ++di)
49
// {
50
// const auto base = math::table::PRIME_TABLE[di];
51
// Digit* const permutationPtr = &(m_permutations[PERMUTATION_OFFSETS(di)]);
52
//
53
// for(Digit digit = 0; digit < base; ++digit)
54
// {
55
// permutationPtr[digit] = digit;
56
// }
57
// math::shuffle_durstenfeld(permutationPtr, permutationPtr + base);
58
// }
59
//}
60
//
61
//inline auto RadicalInversePermutations::getPermutationForDim(const std::size_t dimIndex) const
62
// -> const Digit*
63
//{
64
// PH_ASSERT_LT(dimIndex, MAX_DIMENSIONS);
65
//
66
// const auto offset = PERMUTATION_OFFSETS(dimIndex);
67
// PH_ASSERT_LT(offset + math::table::PRIME_TABLE[dimIndex], m_permutations.size());
68
//
69
// return &(m_permutations[offset]);
70
//}
71
//
72
//inline auto RadicalInversePermutations::PERMUTATION_OFFSETS(const std::size_t dimIndex)
73
// -> Offset
74
//{
75
// static std::vector<Offset> offsets(makePermutationOffsets());
76
//
77
// PH_ASSERT_LT(dimIndex, offsets.size());
78
// return offsets[dimIndex];
79
//}
80
//
81
//inline auto RadicalInversePermutations::makePermutationOffsets()
82
// -> std::vector<Offset>
83
//{
84
// // The offsets are actually a prefix sum of the prime table, but start
85
// // with 0.
86
//
87
// std::vector<Offset> offsets(MAX_DIMENSIONS + 1);
88
// offsets[0] = math::table::PRIME_TABLE[0];
89
// for(std::size_t i = 1; i < offsets.size(); ++i)
90
// {
91
// offsets[i] = offsets[i - 1] + math::table::PRIME_TABLE[i - 1];
92
//
93
// PH_ASSERT_MSG(offsets[i] > offsets[i - 1],
94
// "offsets overflow");
95
// }
96
// return std::move(offsets);
97
//}
98
//
99
//}// end namespace ph::halton::detail
Source
Core
SampleGenerator
Halton
RadicalInversePermutations.h
Generated by
1.11.0