Created
June 16, 2023 12:14
-
-
Save tinylucid/6f42c4e6aba7a75c6b9dbd59a16fdbe2 to your computer and use it in GitHub Desktop.
PCG_RNG hash function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.reedbeta.com/blog/hash-functions-for-gpu-rendering/ | |
uint pcg_hash(uint input) | |
{ | |
uint state = input * 747796405u + 2891336453u; | |
uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; | |
return (word >> 22u) ^ word; | |
} | |
{ | |
uint rng_state; | |
uint rand_pcg() | |
{ | |
uint state = rng_state; | |
rng_state = rng_state * 747796405u + 2891336453u; | |
uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; | |
return (word >> 22u) ^ word; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment