2024-07-10 15:35:19 +10:00
|
|
|
|
|
|
|
int rand_gen(in int n) {
|
|
|
|
n = (n << 13) ^ n;
|
|
|
|
return (n * (n*n*15731+789221) + 1376312589) & 0x7fffffff;
|
|
|
|
}
|
|
|
|
|
|
|
|
float rand_float(inout int n) {
|
|
|
|
n = rand_gen(n);
|
|
|
|
return float(n) / float(0x7fffffff);
|
|
|
|
}
|
|
|
|
|
2024-07-10 23:11:00 +10:00
|
|
|
vec2 rand_vec2(inout int n) {
|
|
|
|
return vec2(rand_float(n), rand_float(n));
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 rand_vec3(inout int n) {
|
|
|
|
return vec3(rand_float(n), rand_float(n), rand_float(n));
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4 rand_vec4(inout int n) {
|
|
|
|
return vec4(rand_float(n), rand_float(n), rand_float(n), rand_float(n));
|
|
|
|
}
|
|
|
|
|
2024-07-10 15:35:19 +10:00
|
|
|
void rand_mix(inout int n, int v) {
|
|
|
|
n = rand_gen(n ^ v);
|
|
|
|
}
|
|
|
|
|