mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Better moonlight, added aurora light
This commit is contained in:
parent
53185639a0
commit
c4efb5fc68
@ -5,8 +5,6 @@ float falloff(float x) {
|
||||
return pow(max(x > 0.577 ? (0.3849 / x - 0.1) : (0.9 - x * x), 0.0), 4);
|
||||
}
|
||||
|
||||
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
|
||||
// for computing light access.
|
||||
float cloud_broad(vec3 pos) {
|
||||
@ -154,8 +152,20 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission, out float not_underground
|
||||
* max(0, 1.0 - abs(textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.00001, 0).x - 0.5) * 4)
|
||||
, 2);
|
||||
float t = clamp((pos.z - emission_alt) / emission_height, 0, 1);
|
||||
|
||||
emission = vec3(t * 1, 2 - t * 2, 0) * 100 * emission_factor * nz;
|
||||
float br = 0.5; // blue vs red
|
||||
#if (CLOUD_MODE > CLOUD_MODE_LOW)
|
||||
br += (magnetosphere_tint.r - 0.6) * 4;
|
||||
#else
|
||||
br = 1.0;
|
||||
#endif
|
||||
br = clamp(br, 0, 1);
|
||||
t = pow(t - 0.5, 2) * sign(t - 0.5) + 0.5;
|
||||
float top = pow(t, 2);
|
||||
float bot = pow(max(0.8 - t, 0), 2) * 2;
|
||||
const vec3 cyan = vec3(0, 0.5, 1);
|
||||
const vec3 red = vec3(1, 0, 0);
|
||||
const vec3 green = vec3(0, 8, 0);
|
||||
emission = 100 * emission_factor * nz * (cyan * top * max(0, 1 - br) + red * max(br, 0) + green * bot);
|
||||
}
|
||||
|
||||
// We track vapor density and air density separately. Why? Because photons will ionize particles in air
|
||||
|
@ -42,6 +42,7 @@ const vec3 NIGHT_LIGHT = vec3(5.0, 0.75, 0.2);
|
||||
const vec3 MU_SCATTER = vec3(0.05, 0.10, 0.23) * 1.5;
|
||||
|
||||
const float SUN_COLOR_FACTOR = 5.0;//6.0;// * 1.5;//1.8;
|
||||
const float MOON_COLOR_FACTOR = 5.0;//6.0;// * 1.5;//1.8;
|
||||
|
||||
const float UNDERWATER_MIST_DIST = 100.0;
|
||||
|
||||
@ -124,6 +125,9 @@ float magnetosphere = sin(time_of_day.x / (3600 * 24));
|
||||
) * 0.4;
|
||||
vec3 magnetosphere_tint = _magnetosphere_change / length(_magnetosphere_change);
|
||||
#endif
|
||||
#if (CLOUD_MODE > CLOUD_MODE_NONE)
|
||||
float emission_strength = clamp((magnetosphere - 0.8) / 0.1, 0, 1) * max(sun_dir.z, 0);
|
||||
#endif
|
||||
|
||||
float get_sun_brightness(/*vec3 sun_dir*/) {
|
||||
return max(-sun_dir.z + 0.5, 0.0);
|
||||
@ -159,7 +163,7 @@ vec3 get_sky_color(/*vec3 sun_dir*/) {
|
||||
}
|
||||
|
||||
vec3 get_moon_color(/*vec3 moon_dir*/) {
|
||||
return vec3(0.05, 0.05, 1.6);
|
||||
return vec3(0.5, 0.5, 1.6);
|
||||
}
|
||||
|
||||
DirectionalLight get_sun_info(vec4 _dir, float shade_frac/*, vec4 light_pos[2]*/, /*vec4 sun_pos*/vec3 f_pos) {
|
||||
@ -262,7 +266,7 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
|
||||
float moon_light = get_moon_brightness(/*moon_dir*/) * moon_info.block;//moon_info.brightness;
|
||||
|
||||
vec3 sun_color = get_sun_color(/*sun_dir*/) * SUN_COLOR_FACTOR;//sun_info.color * SUN_COLOR_FACTOR;
|
||||
vec3 moon_color = get_moon_color(/*moon_dir*/);//moon_info.color;
|
||||
vec3 moon_color = get_moon_color(/*moon_dir*/) * MOON_COLOR_FACTOR;//moon_info.color;
|
||||
|
||||
// If the sun is facing the wrong way, we currently just want zero light, hence default point is wpos.
|
||||
vec3 sun_attenuation = compute_attenuation(wpos, -sun_dir, mu, surface_alt, wpos);
|
||||
@ -385,11 +389,19 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
|
||||
emitted_light = light_frac + k_a * PERSISTENT_AMBIANCE * ambiance * 0.1 * MU_SCATTER;
|
||||
// emitted_light = k_a * light_frac * (/*ambient_sides + */SUN_AMBIANCE * /*sun_light*/sun_chroma + /*vec3(moon_light)*/MOON_AMBIANCE * moon_chroma) + PERSISTENT_AMBIANCE;
|
||||
|
||||
vec3 emission = vec3(0);
|
||||
#if (CLOUD_MODE > CLOUD_MODE_NONE)
|
||||
if (emission_strength > 0.0) {
|
||||
emission = normalize(pow(magnetosphere_tint, vec3(3))) * emission_strength * magnetosphere * 0.1;
|
||||
}
|
||||
#endif
|
||||
|
||||
reflected_light = R_t_r * (
|
||||
(1.0 - SUN_AMBIANCE) * sun_chroma * sun_shadow * (light_reflection_factor(norm, dir, sun_dir, k_d, k_s, alpha, voxel_norm, voxel_lighting) /*+
|
||||
light_reflection_factor(norm, dir, normalize(sun_dir + vec3(0.0, 0.1, 0.0)), k_d, k_s, alpha) +
|
||||
light_reflection_factor(norm, dir, normalize(sun_dir - vec3(0.0, 0.1, 0.0)), k_d, k_s, alpha)*/) +
|
||||
(1.0 - MOON_AMBIANCE) * moon_chroma * moon_shadow * 1.0 * /*4.0 * */light_reflection_factor(norm, dir, moon_dir, k_d, k_s, alpha, voxel_norm, voxel_lighting)
|
||||
(1.0 - MOON_AMBIANCE) * moon_chroma * moon_shadow * 1.0 * /*4.0 * */light_reflection_factor(norm, dir, moon_dir, k_d, k_s, alpha, voxel_norm, voxel_lighting) +
|
||||
emission
|
||||
);
|
||||
|
||||
/* light = sun_chroma + moon_chroma + PERSISTENT_AMBIANCE;
|
||||
|
Loading…
Reference in New Issue
Block a user