Better ambiance slider

This commit is contained in:
Joshua Barretto 2021-10-16 15:12:07 +01:00
parent 3322eeb365
commit ef33b2e3ab
4 changed files with 10 additions and 16 deletions

View File

@ -139,7 +139,7 @@ float get_sun_brightness(/*vec3 sun_dir*/) {
}
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*/) {
@ -268,7 +268,7 @@ 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_COLOR_FACTOR;//moon_info.color;
@ -391,7 +391,7 @@ 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);

View File

@ -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))

View File

@ -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,

View File

@ -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(),