TL;DR these functions return random-looking numbers based on an integer position and seed. And they’re super fast. You can use these for procedural generation, or for anything else that needs a bit of (stateless and reproducible) randomness.
Background
Original C++ code published here by Squirrel Eiserloh. I changed the API a little, grouping the functions by return type - hope you don’t mind.
Recommended talks by the author:
- Math for Game Programmers: Noise-Based RNG
- Math for Game Programmers: Fast and Funky 1D Nonlinear Transformations
- Math for Game Programmers: Juicing Your Cameras With Math
- Math for Game Programmers: Randomness in Games
Installation
Either simply paste the class below into your project, or install it as a package via the Unity Package Manager using this URL:0
https://gist.github.com/eb733523bee790c3b15e9aac39713ef8.git
Source
-
Yes, you can install packages straight from GitHub Gists (if they’re set up with a
package.json
and an.asmdef
). I’m as surprised as you are that this actually works, but Gists are built on top of regular Git repositories, so it makes sense. return ︿