File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#extension GL_EXT_control_flow_attributes : require
22
33// Generates a seed for a random number generator from 2 inputs plus a backoff
4- // https://github.com/nvpro-samples/optix_prime_baking/blob/master/random.h
4+ // https://github.com/nvpro-samples/optix_prime_baking/blob/332a886f1ac46c0b3eea9e89a59593470c755a0e/random.h
5+ // https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR/tree/master/ray_tracing_jitter_cam
56// https://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
67uint InitRandomSeed(uint val0, uint val1)
78{
@@ -26,10 +27,13 @@ uint RandomInt(inout uint seed)
2627
2728float RandomFloat(inout uint seed)
2829{
29- // Float version using bitmask from Numerical Recipes
30- const uint one = 0x3f800000;
31- const uint msk = 0x007fffff;
32- return uintBitsToFloat(one | (msk & (RandomInt(seed) >> 9 ))) - 1 ;
30+ // // Float version using bitmask from Numerical Recipes
31+ // const uint one = 0x3f800000;
32+ // const uint msk = 0x007fffff;
33+ // return uintBitsToFloat(one | (msk & (RandomInt(seed) >> 9))) - 1;
34+
35+ // Faster version from NVIDIA examples; quality good enough for our use case.
36+ return (float (RandomInt(seed) & 0x00FFFFFF) / float (0x01000000));
3337}
3438
3539vec2 RandomInUnitDisk(inout uint seed)
You can’t perform that action at this time.
0 commit comments