From 207568a01292e4e16005990926912c9d4e63271a Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 25 Sep 2019 10:41:51 +0100 Subject: [PATCH] Better day/night cycle, less intense sun --- assets/voxygen/shaders/include/light.glsl | 2 +- assets/voxygen/shaders/include/sky.glsl | 16 ++++++++-------- voxygen/src/mesh/terrain.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/voxygen/shaders/include/light.glsl b/assets/voxygen/shaders/include/light.glsl index cf4c54c1b3..e3f4e8f915 100644 --- a/assets/voxygen/shaders/include/light.glsl +++ b/assets/voxygen/shaders/include/light.glsl @@ -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) { diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index 2ab3bf48f2..ccdc492607 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -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) diff --git a/voxygen/src/mesh/terrain.rs b/voxygen/src/mesh/terrain.rs index 2f32b44e53..49987590a9 100644 --- a/voxygen/src/mesh/terrain.rs +++ b/voxygen/src/mesh/terrain.rs @@ -49,7 +49,7 @@ fn calc_light + 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 {