aboutsummaryrefslogtreecommitdiffstats
path: root/shaders/include/rand.h
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-09-26 23:57:26 +0200
committerladevieq <ladevie.quentin@gmail.com>2021-09-26 23:57:26 +0200
commitc5119193ffaedf4ac94fecfb434a3292a4746259 (patch)
tree398031c5d1e920fec21e53feacd1d55ba8a79dad /shaders/include/rand.h
parentbbba71cfe5a9545f1a87c70eb3cab3b6b08b1b25 (diff)
Refactor gltf loading and triangles attributes
Diffstat (limited to 'shaders/include/rand.h')
-rw-r--r--shaders/include/rand.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/shaders/include/rand.h b/shaders/include/rand.h
new file mode 100644
index 0000000..e1f8b27
--- /dev/null
+++ b/shaders/include/rand.h
@@ -0,0 +1,12 @@
+uint pcg_hash(inout uint seed)
+{
+ uint state = seed;
+ seed *= 747796405u + 2891336453u;
+ uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
+ return (word >> 22u) ^ word;
+}
+
+float rand(inout uint seed)
+{
+ return float(pcg_hash(seed)) / 4294967296.0;
+}