mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added point glow slider
This commit is contained in:
parent
f8783487a8
commit
5a7cd39625
@ -105,6 +105,7 @@
|
||||
"hud.settings.save_window_size": "Save window size",
|
||||
"hud.settings.reset_graphics": "Reset to Defaults",
|
||||
"hud.settings.bloom": "Bloom",
|
||||
"hud.settings.point_glow": "Point Glow",
|
||||
|
||||
"hud.settings.master_volume": "Master Volume",
|
||||
"hud.settings.inactive_master_volume_perc": "Inactive Window Volume",
|
||||
|
@ -54,6 +54,12 @@
|
||||
#define SHADOW_MODE <mode>
|
||||
*/
|
||||
|
||||
/* Constants possibly defined automatically by configuration: */
|
||||
|
||||
/*
|
||||
#define POINT_GLOW_FACTOR <0.0..1.0>
|
||||
*/
|
||||
|
||||
/* Constants expected to be defined by any shader that needs to perform lighting calculations
|
||||
* (but whose values may take automatically defined constants into account): */
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
#define POINT_GLOW_GLSL
|
||||
|
||||
vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color, const float factor) {
|
||||
#ifndef EXPERIMENTAL_NOPOINTGLOW
|
||||
#ifndef POINT_GLOW_FACTOR
|
||||
return color;
|
||||
#else
|
||||
for (uint i = 0u; i < light_shadow_count.x; i ++) {
|
||||
// Only access the array once
|
||||
Light L = lights[i];
|
||||
@ -32,9 +34,10 @@ vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color, const flo
|
||||
|
||||
const float LIGHT_AMBIANCE = 0.025;
|
||||
color += light_color
|
||||
* 0.025
|
||||
* 0.05
|
||||
// Constant, *should* const fold
|
||||
* pow(factor, 0.65);
|
||||
* pow(factor, 0.65)
|
||||
* POINT_GLOW_FACTOR;
|
||||
}
|
||||
#endif
|
||||
return color;
|
||||
|
@ -74,6 +74,9 @@ widget_ids! {
|
||||
bloom_intensity_text,
|
||||
bloom_intensity_slider,
|
||||
bloom_intensity_value,
|
||||
point_glow_text,
|
||||
point_glow_slider,
|
||||
point_glow_value,
|
||||
//
|
||||
upscale_factor_text,
|
||||
upscale_factor_list,
|
||||
@ -727,7 +730,6 @@ impl<'a> Widget for Video<'a> {
|
||||
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))
|
||||
@ -769,12 +771,55 @@ impl<'a> Widget for Video<'a> {
|
||||
})))
|
||||
}
|
||||
}
|
||||
Text::new(&format!("{}%", &bloom_value))
|
||||
.right_from(state.ids.bloom_intensity_slider, 8.0)
|
||||
Text::new(&if bloom_intensity <= f32::EPSILON {
|
||||
"Off".to_string()
|
||||
} else {
|
||||
format!("{}%", (bloom_intensity * 100.0 / max_bloom) as i32)
|
||||
})
|
||||
.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);
|
||||
|
||||
// Point Glow
|
||||
Text::new(self.localized_strings.get("hud.settings.point_glow"))
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.down_from(state.ids.aa_mode_list, 10.0)
|
||||
.right_from(state.ids.bloom_intensity_value, 10.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.bloom_intensity_value, ui);
|
||||
.set(state.ids.point_glow_text, ui);
|
||||
if let Some(new_val) = ImageSlider::continuous(
|
||||
render_mode.point_glow,
|
||||
0.0,
|
||||
1.0,
|
||||
self.imgs.slider_indicator,
|
||||
self.imgs.slider,
|
||||
)
|
||||
.w_h(104.0, 22.0)
|
||||
.down_from(state.ids.point_glow_text, 8.0)
|
||||
.track_breadth(12.0)
|
||||
.slider_length(10.0)
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.point_glow_slider, ui)
|
||||
{
|
||||
// Toggle Bloom On and set Custom value to new_val
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
point_glow: new_val,
|
||||
..render_mode.clone()
|
||||
})));
|
||||
}
|
||||
Text::new(&if render_mode.point_glow <= f32::EPSILON {
|
||||
"Off".to_string()
|
||||
} else {
|
||||
format!("{}%", (render_mode.point_glow * 100.0) as i32)
|
||||
})
|
||||
.right_from(state.ids.point_glow_slider, 8.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.point_glow_value, ui);
|
||||
|
||||
// Upscaling factor
|
||||
Text::new(self.localized_strings.get("hud.settings.upscale_factor"))
|
||||
|
@ -332,7 +332,7 @@ impl BloomMode {
|
||||
}
|
||||
|
||||
/// Render modes
|
||||
#[derive(PartialEq, Clone, Debug, Default, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct RenderMode {
|
||||
pub aa: AaMode,
|
||||
@ -341,6 +341,8 @@ pub struct RenderMode {
|
||||
pub lighting: LightingMode,
|
||||
pub shadow: ShadowMode,
|
||||
pub bloom: BloomMode,
|
||||
/// 0.0..1.0
|
||||
pub point_glow: f32,
|
||||
|
||||
pub experimental_shaders: HashSet<ExperimentalShader>,
|
||||
|
||||
@ -349,6 +351,24 @@ pub struct RenderMode {
|
||||
pub profiler_enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for RenderMode {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
aa: AaMode::default(),
|
||||
cloud: CloudMode::default(),
|
||||
fluid: FluidMode::default(),
|
||||
lighting: LightingMode::default(),
|
||||
shadow: ShadowMode::default(),
|
||||
bloom: BloomMode::default(),
|
||||
point_glow: 0.35,
|
||||
experimental_shaders: HashSet::default(),
|
||||
upscale_mode: UpscaleMode::default(),
|
||||
present_mode: PresentMode::default(),
|
||||
profiler_enabled: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderMode {
|
||||
fn split(self) -> (PipelineModes, OtherModes) {
|
||||
(
|
||||
@ -359,6 +379,7 @@ impl RenderMode {
|
||||
lighting: self.lighting,
|
||||
shadow: self.shadow,
|
||||
bloom: self.bloom,
|
||||
point_glow: self.point_glow,
|
||||
experimental_shaders: self.experimental_shaders,
|
||||
},
|
||||
OtherModes {
|
||||
@ -380,6 +401,7 @@ pub struct PipelineModes {
|
||||
lighting: LightingMode,
|
||||
pub shadow: ShadowMode,
|
||||
bloom: BloomMode,
|
||||
point_glow: f32,
|
||||
experimental_shaders: HashSet<ExperimentalShader>,
|
||||
}
|
||||
|
||||
@ -403,9 +425,6 @@ pub enum ExperimentalShader {
|
||||
NoNoise,
|
||||
/// Simulated a curved world.
|
||||
CurvedWorld,
|
||||
/// Remove the glow effect around point lights (this is *not* the same thing
|
||||
/// as bloom).
|
||||
NoPointGlow,
|
||||
/// Adds extra detail to distant LoD (Level of Detail) terrain procedurally.
|
||||
ProceduralLodDetail,
|
||||
}
|
||||
|
@ -182,6 +182,13 @@ impl ShaderModules {
|
||||
},
|
||||
);
|
||||
|
||||
if pipeline_modes.point_glow > f32::EPSILON {
|
||||
constants += &format!(
|
||||
"\n#define POINT_GLOW_FACTOR {}\n",
|
||||
pipeline_modes.point_glow
|
||||
);
|
||||
}
|
||||
|
||||
for shader in pipeline_modes.experimental_shaders.iter() {
|
||||
constants += &format!(
|
||||
"#define EXPERIMENTAL_{}\n",
|
||||
|
Loading…
Reference in New Issue
Block a user