This is a random gradient generator function for Perlin Noise. The full implementation can be found here. I have little knowledge about RNGs, but the underlying algorithm doesn’t seem to be linear congruential. What algorithm is this? I tried modifying these magic numbers (except for -1.0 and 2.0 I know they’re used to map the result to [-1, 1]) without breaking this function, but I don’t know if it’s always safe to do so.
vec2 random(vec2 uv){
uv = vec2( dot(uv, vec2(127.1,311.7) ),
dot(uv, vec2(269.5,183.3) ) );
return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
}
Also this random gradient generator doesn’t accept any seed (well the uv position is somewhat a seed, but without an extra seed, the generated noise map will always be the same) How can I insert a seed (integer) in this snippet?