More sunset variation for higher graphics modes

This commit is contained in:
Joshua Barretto 2021-07-17 19:00:12 +01:00
parent 54eb2a3ff7
commit 5bdea9249c
2 changed files with 31 additions and 15 deletions

View File

@ -5,7 +5,7 @@ float falloff(float x) {
return pow(max(x > 0.577 ? (0.3849 / x - 0.1) : (0.9 - x * x), 0.0), 4); return pow(max(x > 0.577 ? (0.3849 / x - 0.1) : (0.9 - x * x), 0.0), 4);
} }
float emission_strength = clamp((sin(time_of_day.x / (3600 * 24)) - 0.8) / 0.1, 0, 1); float emission_strength = clamp((magnetosphere - 0.8) / 0.1, 0, 1);
// Return the 'broad' density of the cloud at a position. This gets refined later with extra noise, but is important // Return the 'broad' density of the cloud at a position. This gets refined later with extra noise, but is important
// for computing light access. // for computing light access.
@ -199,7 +199,6 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
splay += (textureLod(sampler2D(t_noise, s_noise), vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 5.0 - time_of_day * 0.00005, 0).x - 0.5) * 0.025 / (1.0 + pow(dir.z, 2) * 10); splay += (textureLod(sampler2D(t_noise, s_noise), vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 5.0 - time_of_day * 0.00005, 0).x - 0.5) * 0.025 / (1.0 + pow(dir.z, 2) * 10);
#endif #endif
/* const float RAYLEIGH = 0.25; */
const vec3 RAYLEIGH = vec3(0.025, 0.1, 0.5); const vec3 RAYLEIGH = vec3(0.025, 0.1, 0.5);
// Proportion of sunlight that get scattered back into the camera by clouds // Proportion of sunlight that get scattered back into the camera by clouds
@ -208,12 +207,15 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
float net_light = get_sun_brightness() + get_moon_brightness(); float net_light = get_sun_brightness() + get_moon_brightness();
vec3 sky_color = RAYLEIGH * net_light; vec3 sky_color = RAYLEIGH * net_light;
vec3 sky_light = get_sky_light(dir, time_of_day, false); vec3 sky_light = get_sky_light(dir, time_of_day, false);
vec3 sun_color = get_sun_color();
vec3 moon_color = get_moon_color();
float cdist = max_dist; float cdist = max_dist;
float ldist = cdist; float ldist = cdist;
// i is an emergency brake // i is an emergency brake
float min_dist = clamp(max_dist / 4, 0.25, 24); float min_dist = clamp(max_dist / 4, 0.25, 24);
for (int i = 0; cdist > min_dist && i < 250; i ++) { int i;
for (i = 0; cdist > min_dist && i < 250; i ++) {
ldist = cdist; ldist = cdist;
cdist = step_to_dist(trunc(dist_to_step(cdist - 0.25, quality)), quality); cdist = step_to_dist(trunc(dist_to_step(cdist - 0.25, quality)), quality);
@ -235,8 +237,8 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
// Attenuate light passing through the clouds // Attenuate light passing through the clouds
surf_color * cloud_darken * global_darken + surf_color * cloud_darken * global_darken +
// Add the directed light light scattered into the camera by the clouds and the atmosphere (global illumination) // Add the directed light light scattered into the camera by the clouds and the atmosphere (global illumination)
get_sun_color() * sun_scatter * get_sun_brightness() * (sun_access * (1.0 - cloud_darken) /*+ sky_color * global_scatter_factor*/) + sun_color * sun_scatter * get_sun_brightness() * (sun_access * (1.0 - cloud_darken) /*+ sky_color * global_scatter_factor*/) +
get_moon_color() * moon_scatter * get_moon_brightness() * (moon_access * (1.0 - cloud_darken) /*+ sky_color * global_scatter_factor*/) + moon_color * moon_scatter * get_moon_brightness() * (moon_access * (1.0 - cloud_darken) /*+ sky_color * global_scatter_factor*/) +
sky_light * (1.0 - global_darken) + sky_light * (1.0 - global_darken) +
emission * density_integrals.y; emission * density_integrals.y;
} }

View File

@ -24,8 +24,8 @@ const vec3 SKY_DAY_BOT = vec3(0.1, 0.2, 0.3);
const vec3 DAY_LIGHT = vec3(3.8, 3.0, 1.8); const vec3 DAY_LIGHT = vec3(3.8, 3.0, 1.8);
const vec3 SUN_HALO_DAY = vec3(0.25, 0.25, 0.001); const vec3 SUN_HALO_DAY = vec3(0.25, 0.25, 0.001);
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20); const vec3 SKY_DUSK_TOP = vec3(1.06, 0.1, 0.20);
const vec3 SKY_DUSK_MID = vec3(0.75, 0.1, 0.15); const vec3 SKY_DUSK_MID = vec3(2.5, 0.3, 0.1);
const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.23); const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.23);
const vec3 DUSK_LIGHT = vec3(8.0, 1.5, 0.15); const vec3 DUSK_LIGHT = vec3(8.0, 1.5, 0.15);
const vec3 SUN_HALO_DUSK = vec3(10.2, 3.0, 0.1); const vec3 SUN_HALO_DUSK = vec3(10.2, 3.0, 0.1);
@ -111,6 +111,20 @@ float cloud_shadow(vec3 pos, vec3 light_dir) {
#endif #endif
} }
float magnetosphere = sin(time_of_day.x / (3600 * 24));
#if (CLOUD_MODE <= CLOUD_MODE_LOW)
const vec3 magnetosphere_tint = vec3(1);
#else
float _magnetosphere2 = pow(magnetosphere, 2) * 2 - 1;
float _magnetosphere3 = pow(_magnetosphere2, 2) * 2 - 1;
vec3 _magnetosphere_change = vec3(1.0) + vec3(
(magnetosphere + 1.0) * 2.0,
(-_magnetosphere2 + 1.0) * 2.0,
(-_magnetosphere3 + 1.0) * 1.0
) * 0.4;
vec3 magnetosphere_tint = _magnetosphere_change / length(_magnetosphere_change);
#endif
float get_sun_brightness(/*vec3 sun_dir*/) { float get_sun_brightness(/*vec3 sun_dir*/) {
return max(-sun_dir.z + 0.5, 0.0); return max(-sun_dir.z + 0.5, 0.0);
} }
@ -122,7 +136,7 @@ float get_moon_brightness(/*vec3 moon_dir*/) {
vec3 get_sun_color(/*vec3 sun_dir*/) { vec3 get_sun_color(/*vec3 sun_dir*/) {
return mix( return mix(
mix( mix(
DUSK_LIGHT, DUSK_LIGHT * magnetosphere_tint,
NIGHT_LIGHT, NIGHT_LIGHT,
max(sun_dir.z, 0) max(sun_dir.z, 0)
), ),
@ -131,12 +145,11 @@ vec3 get_sun_color(/*vec3 sun_dir*/) {
); );
} }
// Average sky colour (i.e: perfectly scattered light from the sky) // Average sky colour (i.e: perfectly scattered light from the sky)
vec3 get_sky_color(/*vec3 sun_dir*/) { vec3 get_sky_color(/*vec3 sun_dir*/) {
return mix( return mix(
mix( mix(
(SKY_DUSK_TOP + SKY_DUSK_MID) / 2, (SKY_DUSK_TOP + SKY_DUSK_MID) / 2 * magnetosphere_tint,
(SKY_NIGHT_TOP + SKY_NIGHT_MID) / 2, (SKY_NIGHT_TOP + SKY_NIGHT_MID) / 2,
max(sun_dir.z, 0) max(sun_dir.z, 0)
), ),
@ -430,7 +443,7 @@ vec3 get_sky_light(vec3 dir, float time_of_day, bool with_stars) {
vec3 sky_top = mix( vec3 sky_top = mix(
mix( mix(
SKY_DUSK_TOP, SKY_DUSK_TOP * magnetosphere_tint,
SKY_NIGHT_TOP, SKY_NIGHT_TOP,
pow(max(sun_dir.z, 0.0), 0.2) pow(max(sun_dir.z, 0.0), 0.2)
) + star, ) + star,
@ -439,7 +452,8 @@ vec3 get_sky_light(vec3 dir, float time_of_day, bool with_stars) {
); );
vec3 sky_mid = mix( vec3 sky_mid = mix(
mix( SKY_DUSK_MID, mix(
SKY_DUSK_MID * magnetosphere_tint,
SKY_NIGHT_MID, SKY_NIGHT_MID,
pow(max(sun_dir.z, 0.0), 0.1) pow(max(sun_dir.z, 0.0), 0.1)
), ),
@ -449,7 +463,7 @@ vec3 get_sky_light(vec3 dir, float time_of_day, bool with_stars) {
vec3 sky_bot = mix( vec3 sky_bot = mix(
mix( mix(
SKY_DUSK_BOT, SKY_DUSK_BOT * magnetosphere_tint,
SKY_NIGHT_BOT, SKY_NIGHT_BOT,
pow(max(sun_dir.z, 0.0), 0.2) pow(max(sun_dir.z, 0.0), 0.2)
), ),
@ -467,7 +481,7 @@ vec3 get_sky_light(vec3 dir, float time_of_day, bool with_stars) {
max(dir.z, 0) max(dir.z, 0)
); );
return sky_color; return sky_color * magnetosphere_tint;
} }
vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float quality, bool with_features, float refractionIndex) { vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float quality, bool with_features, float refractionIndex) {
@ -484,7 +498,7 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
const vec3 SUN_SURF_COLOR = vec3(1.5, 0.9, 0.35) * 50.0; const vec3 SUN_SURF_COLOR = vec3(1.5, 0.9, 0.35) * 50.0;
vec3 sun_halo_color = mix( vec3 sun_halo_color = mix(
SUN_HALO_DUSK, SUN_HALO_DUSK * magnetosphere_tint,
SUN_HALO_DAY, SUN_HALO_DAY,
pow(max(-sun_dir.z, 0.0), 0.5) pow(max(-sun_dir.z, 0.0), 0.5)
); );