mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better hash RNG
This commit is contained in:
parent
1a263834e7
commit
3f7667352d
@ -1,5 +1,5 @@
|
||||
float hash(vec4 p) {
|
||||
p = fract(p * 0.3183099 + 0.1);
|
||||
p = fract(p * 0.3183099 + 0.1) - fract(p + 23.22121);
|
||||
p *= 17.0;
|
||||
return (fract(p.x * p.y * p.z * p.w * (p.x + p.y + p.z + p.w)) - 0.5) * 2.0;
|
||||
}
|
||||
|
@ -94,10 +94,10 @@ float is_star_at(vec3 dir) {
|
||||
vec3 pos = (floor(dir * star_scale) - 0.5) / star_scale;
|
||||
|
||||
// Noisy offsets
|
||||
pos += (3.0 / star_scale) * rand_perm_3(pos);
|
||||
pos += (3.0 / star_scale) * (1.0 + hash(pos.yxzz) * 0.85);
|
||||
|
||||
// Find distance to fragment
|
||||
float dist = length(normalize(pos) - dir);
|
||||
float dist = length(pos - dir);
|
||||
|
||||
// Star threshold
|
||||
if (dist < 0.0015) {
|
||||
|
Loading…
Reference in New Issue
Block a user