MCPcopy Create free account
hub / github.com/aliasIsolation/aliasIsolation / hammersleySample

Function hammersleySample

src/dll/math.h:6–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6inline float hammersleySample(uint bits, uint seed)
7{
8 bits = ( bits << 16u) | ( bits >> 16u);
9 bits = ((bits & 0x00ff00ffu) << 8u) | ((bits & 0xff00ff00u) >> 8u);
10 bits = ((bits & 0x0f0f0f0fu) << 4u) | ((bits & 0xf0f0f0f0u) >> 4u);
11 bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xccccccccu) >> 2u);
12 bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xaaaaaaaau) >> 1u);
13 bits ^= seed;
14 return float(bits) * 2.3283064365386963e-10f; // divide by 1<<32
15}
16
17inline glm::vec2 hammersley2d(uint i, uint N, uint seed) {
18 return glm::vec2(float(float(i) + 0.5f)/float(N), hammersleySample(i, seed));

Callers 1

hammersley2dFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected