Skip to content

Instantly share code, notes, and snippets.

@hiroakioishi
Created June 2, 2020 05:28
Show Gist options
  • Save hiroakioishi/fad4eadaa7fa8b8e49e76baf783d7891 to your computer and use it in GitHub Desktop.
Save hiroakioishi/fad4eadaa7fa8b8e49e76baf783d7891 to your computer and use it in GitHub Desktop.
wang_hash ランダム
// Wang Hash Random
#define WANG_HASH_SEED_MAX 4294967295
#define INV_WANG_HASH_DIV 2.3283064e-10
float wang_hash(uint seed)
{
seed = (seed ^ 61) ^ (seed >> 16);
seed *= 9;
seed = seed ^ (seed >> 4);
seed *= 0x27d4eb2d;
seed = seed ^ (seed >> 15);
return seed * INV_WANG_HASH_DIV;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment