mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Denser stars
This commit is contained in:
parent
ad2bc635f8
commit
397c909bd4
@ -52,29 +52,33 @@ float get_sun_diffuse(vec3 norm, float time_of_day) {
|
||||
}
|
||||
|
||||
vec3 rand_offs(vec3 pos) {
|
||||
return sin(pos * vec3(1473.7 * pos.z, 8891.1 * pos.x, 3813.3 * pos.y));
|
||||
return sin(pos * vec3(1473.7 * pos.z + 472.3, 8891.1 * pos.x + 723.1, 3813.3 * pos.y + 982.5));
|
||||
}
|
||||
|
||||
vec3 get_sky_color(vec3 dir, float time_of_day) {
|
||||
|
||||
// Stars
|
||||
float star_scale = 60.0;
|
||||
float dist = 1000.0;
|
||||
float star_scale = 30.0;
|
||||
float star = 0.0;
|
||||
for (int i = 0; i < 2; i ++) {
|
||||
for (int j = 0; j < 2; j ++) {
|
||||
for (int k = 0; k < 2; k ++) {
|
||||
// Star positions
|
||||
vec3 pos = (floor(dir * star_scale) + vec3(i, j, k) - vec3(0.5)) / star_scale;
|
||||
pos += rand_offs(pos) * 0.2;
|
||||
dist = min(dist, length(normalize(pos) - dir));
|
||||
|
||||
// Noisy offsets
|
||||
pos += 3.0 * rand_offs(pos) / star_scale;
|
||||
|
||||
// Find distance to fragment
|
||||
float dist = length(normalize(pos) - dir);
|
||||
|
||||
// Star threshold
|
||||
if (dist < 0.0015) {
|
||||
star = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float star;
|
||||
if (dist < 0.0015) {
|
||||
star = 1.0;
|
||||
} else {
|
||||
star = 0.0;
|
||||
}
|
||||
|
||||
// Sky color
|
||||
|
||||
|
@ -14,6 +14,7 @@ out vec3 f_pos;
|
||||
void main() {
|
||||
f_pos = v_pos;
|
||||
|
||||
// TODO: Make this position-independent to avoid rounding error jittering
|
||||
gl_Position =
|
||||
proj_mat *
|
||||
view_mat *
|
||||
|
Loading…
Reference in New Issue
Block a user