aboutsummaryrefslogtreecommitdiffstats
path: root/shaders/include/rand.h
diff options
context:
space:
mode:
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;
+}