41 #include <cugar/linalg/vector.h> 59 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
67 const uint32 sx =
permute(s % m, m, p * 0xa511e9b3);
68 const uint32 sy =
permute(s / m, n, p * 0x63d83595);
69 const float jx =
randfloat(s, p * 0xa399d265);
70 const float jy =
randfloat(s, p * 0x711ad6a5);
72 (s % m + (sy + jx) / n) / m,
73 (s / m + (sx + jy) / m) / n );
77 s =
permute(s, m * n, p * 0x51633e2d);
78 const uint32 x = s % m;
79 const uint32 y = s / m;
80 const uint32 sx =
permute(x, m, p * 0x68bc21eb);
81 const uint32 sy =
permute(y, n, p * 0x02e5be93);
85 (sx + (sy + jx) / n) / m,
86 (y + (x + jy) / m) / n );
95 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
97 s(_s), m(_m), n(_n), p(_p), c(-1.0f) {}
99 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
104 const float r = c; c = -1.0f;
126 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE
130 const uint32 x = s % X;
131 const uint32 y = (s / X) % Y;
132 const uint32 z = (s / X) / Y;
134 const uint32 ss =
permute(s, X * Y * Z, p * 0x68bc21eb);
139 const uint32 sz = (ss / X) / Y;
140 const uint32 sx =
permute(x, X, p * 0xa511e9b3 + (z+1) * 0x02e5be93);
141 const uint32 sy =
permute(y, Y, p * 0x63d83595 + (z+1) * 0x51633e2d);
142 const float jx =
randfloat(s, p * 0xa399d265);
143 const float jy =
randfloat(s, p * 0x711ad6a5);
144 const float jz =
randfloat(s, p * 0x368cc8b7);
146 const uint32 ssz =
permute(sz, Z, p * 0x63d83595 + (sx + sy*X) * 19236698399u);
148 const uint32 ssx = ss % X;
149 const uint32 ssy = (ss / X) % Y;
153 (x + (sy + (sz + jx) / Z) / Y) / X,
154 (y + (sz + (sx + jy) / X) / Z) / Y,
157 (sx + (y + (sz + jx) / Z) / Y) / X,
158 (sy + (sz + (x + jy) / X) / Z) / Y,
160 (sx + (sy + (sz + jx) / Z) / Y) / X,
161 (ssy + (sz + (x + jy) / X) / Z) / Y,
163 (ssz + (ssx + (ssy + jz) / Y) / X) / Z );
165 const uint32 z = (s / X) / Y;
166 const uint32 sxy =
permute(s % (X * Y), X * Y, p * 0x51633e2d + z * 0x63d83595);
167 const uint32 x = (sxy % X);
168 const uint32 y = (sxy / X) % Y;
169 const uint32 sx =
permute(x, X, p * 0x68bc21eb);
170 const uint32 sy =
permute(y, Y, p * 0x02e5be93);
171 const uint32 sz =
permute(z, Z, p * 0x51633e2d);
172 const float jx =
randfloat(s, p * 0x967a889b);
173 const float jy =
randfloat(s, p * 0x368cc8b7);
174 const float jz =
randfloat(s, p * 0x711ad6a5);
175 const uint32 ssz =
permute(sz, Z, p * 0x63d83595 + (sx + sy*X) * 19236698399u);
176 const uint32 ssx =
permute(sx, Z, p * 0x63d83595 + (sy + sz*Y) * 19021525571u);
178 (sx + (sy + (sz + jx) / Z) / Y) / X,
179 ( y + ( x + (ssz + jy) / Z) / X) / Y,
180 (ssz + (ssx + (sy + jz) / Y) / X) / Z );
182 const uint32 z = (s / X) / Y;
183 const uint32 sxy =
permute(s % (X * Y), X * Y, p * 0x51633e2d + z * 0x63d83595);
184 const uint32 x = (sxy % X);
185 const uint32 y = (sxy / X) % Y;
187 const uint32 sxz =
permute((s % X) + z * X, X * Z, p * 0x63d83595 + ((s / X) % Y) * 3000004171u);
188 const uint32 ssx = (sxz % X);
189 const uint32 ssz = (sxz / X);
191 const uint32 sx =
permute(x, X, p * 0x68bc21eb);
192 const uint32 sy =
permute(y, Y, p * 0x02e5be93);
193 const uint32 sz =
permute(z, Z, p * 0x51633e2d);
195 const float jx =
randfloat(s, p * 0x967a889b);
196 const float jy =
randfloat(s, p * 0x368cc8b7);
197 const float jz =
randfloat(s, p * 0x711ad6a5);
200 (sx + (sy + (sz + jx) / Z) / Y) / X,
201 ( y + ( x + (ssz + jy) / Z) / X) / Y,
202 (ssz + (ssx + (sy + jz) / Y) / X) / Z );
223 template <
typename T>
225 const uint32 samples_x,
226 const uint32 samples_y,
228 Ordering ordering = kRandom);
233 template <
typename T>
235 const uint32 samples_x,
236 const uint32 samples_y,
241 template <
typename T>
243 const uint32 samples_x,
244 const uint32 samples_y,
246 Ordering ordering = kRandom);
253 std::vector<Sample> m_sample_xy;
265 #include <cugar/sampling/multijitter_inline.h> Definition: multijitter.h:209
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 permute(uint32 i, uint32 l, uint32 p)
Definition: numbers.h:836
MJSampler(const uint32 seed=0)
Definition: multijitter.h:219
Definition: multijitter.h:248
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float3 correlated_multijitter_3d(uint32 s, const uint32 X, const uint32 Y, const uint32 Z, const uint32 p)
Definition: multijitter.h:127
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
Defines several random samplers.
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float2 correlated_multijitter(uint32 s, const uint32 m, const uint32 n, const uint32 p, bool ordered=false)
Definition: multijitter.h:63
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE float randfloat(unsigned i, unsigned p)
Definition: numbers.h:753