Bloom settings

This commit is contained in:
Monty Marz 2021-09-08 09:50:37 +00:00
parent 14bea533e7
commit a23433b402
4 changed files with 78 additions and 10 deletions

View File

@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Sprite pickup animations - Sprite pickup animations
- Add VELOREN_ASSETS_OVERRIDE variable for specifying folder to partially override assets. - Add VELOREN_ASSETS_OVERRIDE variable for specifying folder to partially override assets.
- Cultist raiders - Cultist raiders
- Bloom Slider
### Changed ### Changed

View File

@ -100,6 +100,7 @@
"hud.settings.lod_detail": "LoD Detail", "hud.settings.lod_detail": "LoD Detail",
"hud.settings.save_window_size": "Save window size", "hud.settings.save_window_size": "Save window size",
"hud.settings.reset_graphics": "Reset to Defaults", "hud.settings.reset_graphics": "Reset to Defaults",
"hud.settings.bloom": "Bloom",
"hud.settings.master_volume": "Master Volume", "hud.settings.master_volume": "Master Volume",
"hud.settings.inactive_master_volume_perc": "Inactive Window Volume", "hud.settings.inactive_master_volume_perc": "Inactive Window Volume",

View File

@ -6,8 +6,8 @@ use crate::{
TEXT_COLOR, TEXT_COLOR,
}, },
render::{ render::{
AaMode, CloudMode, FluidMode, LightingMode, PresentMode, RenderMode, ShadowMapMode, AaMode, BloomConfig, BloomFactor, BloomMode, CloudMode, FluidMode, LightingMode,
ShadowMode, UpscaleMode, PresentMode, RenderMode, ShadowMapMode, ShadowMode, UpscaleMode,
}, },
session::settings_change::Graphics as GraphicsChange, session::settings_change::Graphics as GraphicsChange,
settings::Fps, settings::Fps,
@ -67,6 +67,11 @@ widget_ids! {
ambiance_value, ambiance_value,
aa_mode_text, aa_mode_text,
aa_mode_list, aa_mode_list,
//
bloom_intensity_text,
bloom_intensity_slider,
bloom_intensity_value,
//
upscale_factor_text, upscale_factor_text,
upscale_factor_list, upscale_factor_list,
cloud_mode_text, cloud_mode_text,
@ -101,6 +106,7 @@ widget_ids! {
shadow_mode_map_resolution_slider, shadow_mode_map_resolution_slider,
shadow_mode_map_resolution_value, shadow_mode_map_resolution_value,
save_window_size_button, save_window_size_button,
} }
} }
@ -646,9 +652,64 @@ impl<'a> Widget for Video<'a> {
}))); })));
} }
// Bloom
let bloom_intensity = match render_mode.bloom {
BloomMode::Off => 0.0,
BloomMode::On(bloom) => bloom.factor.fraction(),
};
let max_bloom = 0.3;
let bloom_value = ((bloom_intensity * 100.0 / max_bloom) as i32).to_string();
Text::new(self.localized_strings.get("hud.settings.bloom"))
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.down_from(state.ids.aa_mode_list, 10.0)
.color(TEXT_COLOR)
.set(state.ids.bloom_intensity_text, ui);
if let Some(new_val) = ImageSlider::continuous(
bloom_intensity,
0.0,
max_bloom,
self.imgs.slider_indicator,
self.imgs.slider,
)
.w_h(104.0, 22.0)
.down_from(state.ids.bloom_intensity_text, 8.0)
.track_breadth(12.0)
.slider_length(10.0)
.pad_track((5.0, 5.0))
.set(state.ids.bloom_intensity_slider, ui)
{
if new_val > f32::EPSILON {
// Toggle Bloom On and set Custom value to new_val
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
bloom: {
BloomMode::On(BloomConfig {
factor: BloomFactor::Custom(new_val),
// TODO: Decide if this should be a separate setting
uniform_blur: false,
})
},
..render_mode.clone()
})))
} else {
// Toggle Bloom Off if the value is near 0
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
bloom: { BloomMode::Off },
..render_mode.clone()
})))
}
}
Text::new(&format!("{}%", &bloom_value))
.right_from(state.ids.bloom_intensity_slider, 8.0)
.font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id)
.color(TEXT_COLOR)
.set(state.ids.bloom_intensity_value, ui);
// Upscaling factor // Upscaling factor
Text::new(self.localized_strings.get("hud.settings.upscale_factor")) Text::new(self.localized_strings.get("hud.settings.upscale_factor"))
.down_from(state.ids.aa_mode_list, 8.0) .down_from(state.ids.bloom_intensity_slider, 8.0)
.font_size(self.fonts.cyri.scale(14)) .font_size(self.fonts.cyri.scale(14))
.font_id(self.fonts.cyri.conrod_id) .font_id(self.fonts.cyri.conrod_id)
.color(TEXT_COLOR) .color(TEXT_COLOR)

View File

@ -275,11 +275,11 @@ pub enum BloomFactor {
Custom(f32), Custom(f32),
// other variant has to be placed last // other variant has to be placed last
#[serde(other)] #[serde(other)]
Standard, Medium,
} }
impl Default for BloomFactor { impl Default for BloomFactor {
fn default() -> Self { Self::Standard } fn default() -> Self { Self::Low }
} }
impl BloomFactor { impl BloomFactor {
@ -287,7 +287,7 @@ impl BloomFactor {
pub fn fraction(self) -> f32 { pub fn fraction(self) -> f32 {
match self { match self {
Self::Low => 0.05, Self::Low => 0.05,
Self::Standard => 0.10, Self::Medium => 0.10,
Self::High => 0.25, Self::High => 0.25,
Self::Custom(val) => val.max(0.0).min(1.0), Self::Custom(val) => val.max(0.0).min(1.0),
} }
@ -299,14 +299,14 @@ impl BloomFactor {
pub struct BloomConfig { pub struct BloomConfig {
/// Controls fraction of output image luminosity that is blurred bloom /// Controls fraction of output image luminosity that is blurred bloom
/// ///
/// Defaults to `Standard` /// Defaults to `Low`
factor: BloomFactor, pub factor: BloomFactor,
/// Turning this on make the bloom blur less sharply concentrated around the /// Turning this on make the bloom blur less sharply concentrated around the
/// high intensity phenomena (removes adding in less blurred layers to the /// high intensity phenomena (removes adding in less blurred layers to the
/// final blur) /// final blur)
/// ///
/// Defaults to `false` /// Defaults to `false`
uniform_blur: bool, pub uniform_blur: bool,
// TODO: allow configuring the blur radius and/or the number of passes // TODO: allow configuring the blur radius and/or the number of passes
} }
@ -318,7 +318,12 @@ pub enum BloomMode {
} }
impl Default for BloomMode { impl Default for BloomMode {
fn default() -> Self { Self::Off } fn default() -> Self {
Self::On(BloomConfig {
factor: BloomFactor::default(),
uniform_blur: false,
})
}
} }
impl BloomMode { impl BloomMode {