mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'zesterer/tiny-fixes' into 'master'
Tiny fixes See merge request veloren/veloren!2926
This commit is contained in:
commit
94b0288180
@ -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) {
|
||||
@ -142,14 +140,25 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission, out float not_underground
|
||||
if (emission_strength <= 0.0) {
|
||||
emission = vec3(0);
|
||||
} else {
|
||||
float emission_alt = CLOUD_AVG_ALT * 2.0 + (noise_3d(vec3(wind_pos.xy * 0.0001 + cloud_tendency * 0.2, time_of_day.x * 0.0002)) - 0.5) * 6000;
|
||||
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
|
||||
emission_alt += (noise_3d(vec3(wind_pos.xy * 0.0005 + cloud_tendency * 0.2, emission_alt * 0.0001 + time_of_day.x * 0.001)) - 0.5) * 1000;
|
||||
#endif
|
||||
float tail = (textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.00005, 0).x - 0.5) * 4 + (pos.z - emission_alt) * 0.0001;
|
||||
vec3 emission_col = vec3(0.8 + tail * 1.5, 0.5 - tail * 0.2, 0.3 + tail * 0.2);
|
||||
float emission_nz = max(pow(textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.000015, 0).x, 8), 0.01) * 0.25 / (10.0 + abs(pos.z - emission_alt) / 80);
|
||||
emission = emission_col * emission_nz * emission_strength * max(sun_dir.z, 0) * 500000 / (1000.0 + abs(pos.z - emission_alt) * 0.1);
|
||||
float nz = textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.00005 - time_of_day.x * 0.0001, 0).x;//noise_3d(vec3(wind_pos.xy * 0.00005 + cloud_tendency * 0.2, time_of_day.x * 0.0002));
|
||||
|
||||
float emission_alt = alt * 0.5 + 1000 + 1000 * nz;
|
||||
float emission_height = 1000.0;
|
||||
float emission_factor = pow(max(0.0, 1.0 - abs((pos.z - emission_alt) / emission_height - 1.0))
|
||||
* max(0, 1.0 - abs(0.0
|
||||
+ textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.0001 + nz * 0.1, 0).x
|
||||
+ textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.0005 + nz * 0.5, 0).x * 0.3
|
||||
- 0.5) * 2)
|
||||
* max(0, 1.0 - abs(textureLod(sampler2D(t_noise, s_noise), wind_pos.xy * 0.00001, 0).x - 0.5) * 4)
|
||||
, 2) * emission_strength;
|
||||
float t = clamp((pos.z - emission_alt) / emission_height, 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 = 10 * emission_factor * nz * (cyan * top * max(0, 1 - emission_br) + red * max(emission_br, 0) + green * bot);
|
||||
}
|
||||
|
||||
// We track vapor density and air density separately. Why? Because photons will ionize particles in air
|
||||
@ -231,8 +240,9 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
|
||||
float cloud_scatter_factor = density_integrals.x;
|
||||
float global_scatter_factor = density_integrals.y;
|
||||
|
||||
float cloud_darken = pow(1.0 / (1.0 + cloud_scatter_factor), (ldist - cdist) * 0.01);
|
||||
float global_darken = pow(1.0 / (1.0 + global_scatter_factor), (ldist - cdist) * 0.01);
|
||||
float step = (ldist - cdist) * 0.01;
|
||||
float cloud_darken = pow(1.0 / (1.0 + cloud_scatter_factor), step);
|
||||
float global_darken = pow(1.0 / (1.0 + global_scatter_factor), step);
|
||||
|
||||
surf_color =
|
||||
// Attenuate light passing through the clouds
|
||||
@ -241,7 +251,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
|
||||
sun_color * sun_scatter * get_sun_brightness() * (sun_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) * not_underground +
|
||||
emission * density_integrals.y;
|
||||
emission * density_integrals.y * step;
|
||||
}
|
||||
|
||||
return surf_color;
|
||||
|
@ -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,13 +125,21 @@ 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.3) * 1.3, 0, 1) * max(-moon_dir.z, 0);
|
||||
#if (CLOUD_MODE > CLOUD_MODE_MEDIUM)
|
||||
float emission_br = abs(pow(fract(time_of_day.x * 0.000005) * 2 - 1, 2));
|
||||
#else
|
||||
float emission_br = 0.5;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float get_sun_brightness(/*vec3 sun_dir*/) {
|
||||
return max(-sun_dir.z + 0.5, 0.0);
|
||||
}
|
||||
|
||||
float get_moon_brightness(/*vec3 moon_dir*/) {
|
||||
return max(-moon_dir.z + 0.6, 0.0) * 0.05;
|
||||
return max(-moon_dir.z + 0.6, 0.0) * 0.1;
|
||||
}
|
||||
|
||||
vec3 get_sun_color(/*vec3 sun_dir*/) {
|
||||
@ -159,7 +168,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) {
|
||||
@ -259,10 +268,10 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
|
||||
vec3 moon_dir = moon_dir.xyz;
|
||||
|
||||
float sun_light = get_sun_brightness(/*sun_dir*/) * sun_info.block;//sun_info.brightness;;
|
||||
float moon_light = get_moon_brightness(/*moon_dir*/) * moon_info.block;//moon_info.brightness;
|
||||
float moon_light = get_moon_brightness(/*moon_dir*/) * moon_info.block * ambiance;//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);
|
||||
@ -382,14 +391,22 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
|
||||
// float ambient_sides = 0.5 - 0.5 * min(abs(dot(-norm, sun_dir)), abs(dot(-norm, moon_dir)));
|
||||
// float ambient_sides = clamp(mix(0.5, 0.0, abs(dot(-norm, sun_dir)) * mix(0.0, 1.0, abs(sun_dir.z) * 10000.0) * 10000.0), 0.0, 0.5);
|
||||
// float ambient_sides = clamp(mix(0.5, 0.0, abs(dot(-norm, sun_dir)) * mix(0.0, 1.0, abs(sun_dir.z) * 10000.0) * 10000.0), 0.0, 0.5);
|
||||
emitted_light = light_frac + k_a * PERSISTENT_AMBIANCE * ambiance * 0.1 * MU_SCATTER;
|
||||
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 = mix(vec3(0, 0.5, 1), vec3(1, 0, 0), emission_br) * emission_strength * 0.025;
|
||||
}
|
||||
#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;
|
||||
|
@ -1689,9 +1689,10 @@ impl Hud {
|
||||
&self.fonts,
|
||||
)
|
||||
.set(overitem_id, ui_widgets);
|
||||
} else if let Some(sprite) = block.get_sprite() {
|
||||
} else if let Some(desc) = block.get_sprite().and_then(|s| get_sprite_desc(s, i18n))
|
||||
{
|
||||
overitem::Overitem::new(
|
||||
get_sprite_desc(sprite, i18n),
|
||||
desc,
|
||||
overitem::TEXT_COLOR,
|
||||
pos.distance_squared(player_pos),
|
||||
&self.fonts,
|
||||
@ -4053,8 +4054,9 @@ pub fn get_buff_desc(buff: BuffKind, data: BuffData, localized_strings: &Localiz
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_sprite_desc(sprite: SpriteKind, localized_strings: &Localization) -> Cow<str> {
|
||||
pub fn get_sprite_desc(sprite: SpriteKind, localized_strings: &Localization) -> Option<Cow<str>> {
|
||||
let i18n_key = match sprite {
|
||||
SpriteKind::Empty => return None,
|
||||
SpriteKind::Anvil => "hud.crafting.anvil",
|
||||
SpriteKind::Cauldron => "hud.crafting.cauldron",
|
||||
SpriteKind::CookingPot => "hud.crafting.cooking_pot",
|
||||
@ -4063,9 +4065,9 @@ pub fn get_sprite_desc(sprite: SpriteKind, localized_strings: &Localization) ->
|
||||
SpriteKind::Loom => "hud.crafting.loom",
|
||||
SpriteKind::SpinningWheel => "hud.crafting.spinning_wheel",
|
||||
SpriteKind::TanningRack => "hud.crafting.tanning_rack",
|
||||
sprite => return Cow::Owned(format!("{:?}", sprite)),
|
||||
sprite => return Some(Cow::Owned(format!("{:?}", sprite))),
|
||||
};
|
||||
Cow::Borrowed(localized_strings.get(i18n_key))
|
||||
Some(Cow::Borrowed(localized_strings.get(i18n_key)))
|
||||
}
|
||||
|
||||
pub fn get_buff_time(buff: BuffInfo) -> String {
|
||||
|
@ -568,13 +568,10 @@ impl<'a> Widget for Video<'a> {
|
||||
.set(state.ids.exposure_value, ui);
|
||||
|
||||
//Ambiance Brightness
|
||||
// 320.0 = maximum brightness in shaders
|
||||
let min_ambiance = 10.0;
|
||||
let max_ambiance = 80.0;
|
||||
if let Some(new_val) = ImageSlider::discrete(
|
||||
self.global_state.settings.graphics.ambiance.round() as i32,
|
||||
min_ambiance as i32,
|
||||
max_ambiance as i32,
|
||||
(self.global_state.settings.graphics.ambiance * 100.0).round() as i32,
|
||||
0,
|
||||
100,
|
||||
self.imgs.slider_indicator,
|
||||
self.imgs.slider,
|
||||
)
|
||||
@ -585,7 +582,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.ambiance_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeAmbiance(new_val as f32));
|
||||
events.push(GraphicsChange::ChangeAmbiance(new_val as f32 / 100.0));
|
||||
}
|
||||
Text::new(self.localized_strings.get("hud.settings.ambiance"))
|
||||
.up_from(state.ids.ambiance_slider, 8.0)
|
||||
@ -595,10 +592,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.set(state.ids.ambiance_text, ui);
|
||||
Text::new(&format!(
|
||||
"{:.0}%",
|
||||
((self.global_state.settings.graphics.ambiance - min_ambiance)
|
||||
/ (max_ambiance - min_ambiance)
|
||||
* 100.0)
|
||||
.round()
|
||||
(self.global_state.settings.graphics.ambiance * 100.0).round()
|
||||
))
|
||||
.right_from(state.ids.ambiance_slider, 8.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
|
@ -149,7 +149,7 @@ impl Globals {
|
||||
.unwrap_or_else(Vec4::zero)
|
||||
.into_array(),
|
||||
gamma_exposure: [gamma, exposure, 0.0, 0.0],
|
||||
ambiance,
|
||||
ambiance: ambiance.clamped(0.0, 1.0),
|
||||
cam_mode: cam_mode as u32,
|
||||
sprite_render_distance,
|
||||
globals_dummy: 0.0,
|
||||
|
@ -59,7 +59,7 @@ impl Default for GraphicsSettings {
|
||||
fov: 70,
|
||||
gamma: 1.0,
|
||||
exposure: 1.0,
|
||||
ambiance: 10.0,
|
||||
ambiance: 0.5,
|
||||
render_mode: RenderMode::default(),
|
||||
window_size: [1280, 720],
|
||||
fullscreen: FullScreenSettings::default(),
|
||||
|
Loading…
Reference in New Issue
Block a user