mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better day/night cycle, less intense sun
This commit is contained in:
parent
dec418d1a4
commit
207568a012
@ -12,7 +12,7 @@ uniform u_lights {
|
||||
|
||||
vec3 illuminate(vec3 color, vec3 light, vec3 diffuse, vec3 ambience) {
|
||||
float avg_col = (color.r + color.g + color.b) / 3.0;
|
||||
return ((color - avg_col) * light + (diffuse + ambience) * avg_col) * (diffuse + ambience);
|
||||
return ((color - avg_col) * light + (diffuse + ambience) * avg_col) * (diffuse);
|
||||
}
|
||||
|
||||
float attenuation_strength(vec3 rpos) {
|
||||
|
@ -26,12 +26,12 @@ vec3 get_sun_dir(float time_of_day) {
|
||||
return sun_dir;
|
||||
}
|
||||
|
||||
const float PERSISTENT_AMBIANCE = 0.1;
|
||||
|
||||
float get_sun_brightness(vec3 sun_dir) {
|
||||
return max(-sun_dir.z + 0.6, 0.0);
|
||||
}
|
||||
|
||||
const float PERSISTENT_AMBIANCE = 0.1;
|
||||
|
||||
void get_sun_diffuse(vec3 norm, float time_of_day, out vec3 light, out vec3 diffuse_light, out vec3 ambient_light) {
|
||||
const float SUN_AMBIANCE = 0.1;
|
||||
|
||||
@ -53,9 +53,9 @@ void get_sun_diffuse(vec3 norm, float time_of_day, out vec3 light, out vec3 diff
|
||||
|
||||
vec3 sun_chroma = sun_color * sun_light;
|
||||
|
||||
light = vec3(sun_chroma + PERSISTENT_AMBIANCE);
|
||||
diffuse_light = sun_chroma * (dot(-norm, sun_dir) * 0.5 + 0.5);
|
||||
ambient_light = vec3(SUN_AMBIANCE * sun_light + PERSISTENT_AMBIANCE);
|
||||
light = sun_chroma + PERSISTENT_AMBIANCE;
|
||||
diffuse_light = sun_chroma * (dot(-norm, sun_dir) * 0.5 + 0.6) + PERSISTENT_AMBIANCE;
|
||||
ambient_light = vec3(SUN_AMBIANCE * sun_light);
|
||||
}
|
||||
|
||||
// This has been extracted into a function to allow quick exit when detecting a star.
|
||||
@ -101,7 +101,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, bool with_stars) {
|
||||
mix(
|
||||
SKY_DUSK_TOP + star,
|
||||
SKY_NIGHT_TOP + star,
|
||||
max(sun_dir.z, 0)
|
||||
max(pow(sun_dir.z, 0.2), 0)
|
||||
),
|
||||
SKY_DAY_TOP,
|
||||
max(-sun_dir.z, 0)
|
||||
@ -111,7 +111,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, bool with_stars) {
|
||||
mix(
|
||||
SKY_DUSK_MID,
|
||||
SKY_NIGHT_MID,
|
||||
max(sun_dir.z, 0)
|
||||
max(pow(sun_dir.z, 0.2), 0)
|
||||
),
|
||||
SKY_DAY_MID,
|
||||
max(-sun_dir.z, 0)
|
||||
@ -121,7 +121,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, bool with_stars) {
|
||||
mix(
|
||||
SKY_DUSK_BOT,
|
||||
SKY_NIGHT_BOT,
|
||||
max(sun_dir.z, 0)
|
||||
max(pow(sun_dir.z, 0.2), 0)
|
||||
),
|
||||
SKY_DAY_BOT,
|
||||
max(-sun_dir.z, 0)
|
||||
|
@ -49,7 +49,7 @@ fn calc_light<V: RectRasterableVol<Vox = Block> + ReadVol + Debug>(
|
||||
for z in (0..outer.size().d).rev() {
|
||||
if vol
|
||||
.get(outer.min + Vec3::new(x, y, z))
|
||||
.map(|vox| vox.is_air())
|
||||
.map(|vox| vox.is_air() || vox.is_fluid())
|
||||
.unwrap_or(true)
|
||||
{
|
||||
if !outside {
|
||||
|
Loading…
Reference in New Issue
Block a user