mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Bloom settings
This commit is contained in:
parent
14bea533e7
commit
a23433b402
@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Sprite pickup animations
|
||||
- Add VELOREN_ASSETS_OVERRIDE variable for specifying folder to partially override assets.
|
||||
- Cultist raiders
|
||||
- Bloom Slider
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -100,6 +100,7 @@
|
||||
"hud.settings.lod_detail": "LoD Detail",
|
||||
"hud.settings.save_window_size": "Save window size",
|
||||
"hud.settings.reset_graphics": "Reset to Defaults",
|
||||
"hud.settings.bloom": "Bloom",
|
||||
|
||||
"hud.settings.master_volume": "Master Volume",
|
||||
"hud.settings.inactive_master_volume_perc": "Inactive Window Volume",
|
||||
|
@ -6,8 +6,8 @@ use crate::{
|
||||
TEXT_COLOR,
|
||||
},
|
||||
render::{
|
||||
AaMode, CloudMode, FluidMode, LightingMode, PresentMode, RenderMode, ShadowMapMode,
|
||||
ShadowMode, UpscaleMode,
|
||||
AaMode, BloomConfig, BloomFactor, BloomMode, CloudMode, FluidMode, LightingMode,
|
||||
PresentMode, RenderMode, ShadowMapMode, ShadowMode, UpscaleMode,
|
||||
},
|
||||
session::settings_change::Graphics as GraphicsChange,
|
||||
settings::Fps,
|
||||
@ -67,6 +67,11 @@ widget_ids! {
|
||||
ambiance_value,
|
||||
aa_mode_text,
|
||||
aa_mode_list,
|
||||
//
|
||||
bloom_intensity_text,
|
||||
bloom_intensity_slider,
|
||||
bloom_intensity_value,
|
||||
//
|
||||
upscale_factor_text,
|
||||
upscale_factor_list,
|
||||
cloud_mode_text,
|
||||
@ -101,6 +106,7 @@ widget_ids! {
|
||||
shadow_mode_map_resolution_slider,
|
||||
shadow_mode_map_resolution_value,
|
||||
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
|
||||
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_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
|
@ -275,11 +275,11 @@ pub enum BloomFactor {
|
||||
Custom(f32),
|
||||
// other variant has to be placed last
|
||||
#[serde(other)]
|
||||
Standard,
|
||||
Medium,
|
||||
}
|
||||
|
||||
impl Default for BloomFactor {
|
||||
fn default() -> Self { Self::Standard }
|
||||
fn default() -> Self { Self::Low }
|
||||
}
|
||||
|
||||
impl BloomFactor {
|
||||
@ -287,7 +287,7 @@ impl BloomFactor {
|
||||
pub fn fraction(self) -> f32 {
|
||||
match self {
|
||||
Self::Low => 0.05,
|
||||
Self::Standard => 0.10,
|
||||
Self::Medium => 0.10,
|
||||
Self::High => 0.25,
|
||||
Self::Custom(val) => val.max(0.0).min(1.0),
|
||||
}
|
||||
@ -299,14 +299,14 @@ impl BloomFactor {
|
||||
pub struct BloomConfig {
|
||||
/// Controls fraction of output image luminosity that is blurred bloom
|
||||
///
|
||||
/// Defaults to `Standard`
|
||||
factor: BloomFactor,
|
||||
/// Defaults to `Low`
|
||||
pub factor: BloomFactor,
|
||||
/// Turning this on make the bloom blur less sharply concentrated around the
|
||||
/// high intensity phenomena (removes adding in less blurred layers to the
|
||||
/// final blur)
|
||||
///
|
||||
/// Defaults to `false`
|
||||
uniform_blur: bool,
|
||||
pub uniform_blur: bool,
|
||||
// TODO: allow configuring the blur radius and/or the number of passes
|
||||
}
|
||||
|
||||
@ -318,7 +318,12 @@ pub enum BloomMode {
|
||||
}
|
||||
|
||||
impl Default for BloomMode {
|
||||
fn default() -> Self { Self::Off }
|
||||
fn default() -> Self {
|
||||
Self::On(BloomConfig {
|
||||
factor: BloomFactor::default(),
|
||||
uniform_blur: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl BloomMode {
|
||||
|
Loading…
Reference in New Issue
Block a user