mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add setting to disable flashing lights
This commit is contained in:
parent
a9946a491e
commit
cfdc2a8ae6
@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- More varied ambient birdcalls
|
||||
- Cave biomes
|
||||
- Updated the Polish translation
|
||||
- Setting for disabling flashing lights
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -94,6 +94,8 @@
|
||||
"hud.settings.particles": "Particles",
|
||||
"hud.settings.lossy_terrain_compression": "Lossy terrain compression",
|
||||
"hud.settings.weapon_trails": "Weapon trails",
|
||||
"hud.settings.flashing_lights": "Flashing lights",
|
||||
"hud.settings.flashing_lights_info": "Disables all kinds of flashing, e.g. flickering or lightning strikes",
|
||||
"hud.settings.resolution": "Resolution",
|
||||
"hud.settings.bit_depth": "Bit Depth",
|
||||
"hud.settings.refresh_rate": "Refresh Rate",
|
||||
|
@ -56,11 +56,14 @@ vec3 apply_point_glow(vec3 wpos, vec3 dir, float max_dist, vec3 color) {
|
||||
apply_point_glow_light(L, wpos, dir, max_dist, color);
|
||||
}
|
||||
#endif
|
||||
float time_since_lightning = tick.x - last_lightning.w;
|
||||
if (time_since_lightning < MAX_LIGHTNING_PERIOD) {
|
||||
// Apply lightning
|
||||
apply_point_glow_light(Light(last_lightning.xyzw + vec4(0, 0, LIGHTNING_HEIGHT, 0), vec4(vec3(0.2, 0.4, 1) * lightning_intensity() * 0.003, 1)), wpos, dir, max_dist, color);
|
||||
}
|
||||
|
||||
#ifdef FLASHING_LIGHTS_ENABLED
|
||||
float time_since_lightning = tick.x - last_lightning.w;
|
||||
if (time_since_lightning < MAX_LIGHTNING_PERIOD) {
|
||||
// Apply lightning
|
||||
apply_point_glow_light(Light(last_lightning.xyzw + vec4(0, 0, LIGHTNING_HEIGHT, 0), vec4(vec3(0.2, 0.4, 1) * lightning_intensity() * 0.003, 1)), wpos, dir, max_dist, color);
|
||||
}
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
|
||||
|
@ -459,13 +459,19 @@ float get_sun_diffuse2(DirectionalLight sun_info, DirectionalLight moon_info, ve
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FLASHING_LIGHTS_ENABLED
|
||||
vec3 lightning = lightning_at(wpos);
|
||||
#else
|
||||
vec3 lightning = vec3(0);
|
||||
#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) +
|
||||
emission
|
||||
) + lightning_at(wpos);
|
||||
) + lightning;
|
||||
|
||||
/* light = sun_chroma + moon_chroma + PERSISTENT_AMBIANCE;
|
||||
diffuse_light =
|
||||
|
@ -106,6 +106,9 @@ widget_ids! {
|
||||
lossy_terrain_compression_label,
|
||||
weapon_trails_button,
|
||||
weapon_trails_label,
|
||||
flashing_lights_button,
|
||||
flashing_lights_label,
|
||||
flashing_lights_info_label,
|
||||
//
|
||||
fullscreen_button,
|
||||
fullscreen_label,
|
||||
@ -1270,6 +1273,53 @@ impl<'a> Widget for Video<'a> {
|
||||
));
|
||||
}
|
||||
|
||||
// Disable flashing lights
|
||||
Text::new(self.localized_strings.get("hud.settings.flashing_lights"))
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.down_from(state.ids.particles_label, 25.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.flashing_lights_label, ui);
|
||||
|
||||
let flashing_lights_enabled = ToggleButton::new(
|
||||
self.global_state
|
||||
.settings
|
||||
.graphics
|
||||
.render_mode
|
||||
.flashing_lights_enabled,
|
||||
self.imgs.checkbox,
|
||||
self.imgs.checkbox_checked,
|
||||
)
|
||||
.w_h(18.0, 18.0)
|
||||
.right_from(state.ids.flashing_lights_label, 10.0)
|
||||
.hover_images(self.imgs.checkbox_mo, self.imgs.checkbox_checked_mo)
|
||||
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||
.set(state.ids.flashing_lights_button, ui);
|
||||
|
||||
Text::new(
|
||||
self.localized_strings
|
||||
.get("hud.settings.flashing_lights_info"),
|
||||
)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.right_from(state.ids.flashing_lights_label, 32.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.flashing_lights_info_label, ui);
|
||||
|
||||
if self
|
||||
.global_state
|
||||
.settings
|
||||
.graphics
|
||||
.render_mode
|
||||
.flashing_lights_enabled
|
||||
!= flashing_lights_enabled
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
flashing_lights_enabled,
|
||||
..render_mode.clone()
|
||||
})));
|
||||
}
|
||||
|
||||
// Resolution
|
||||
let resolutions: Vec<[u16; 2]> = state
|
||||
.video_modes
|
||||
@ -1283,7 +1333,7 @@ impl<'a> Widget for Video<'a> {
|
||||
Text::new(self.localized_strings.get("hud.settings.resolution"))
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.down_from(state.ids.particles_label, 8.0)
|
||||
.down_from(state.ids.flashing_lights_label, 25.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.resolution_label, ui);
|
||||
|
||||
@ -1342,7 +1392,7 @@ impl<'a> Widget for Video<'a> {
|
||||
Text::new(self.localized_strings.get("hud.settings.bit_depth"))
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.down_from(state.ids.particles_label, 8.0)
|
||||
.down_from(state.ids.flashing_lights_label, 25.0)
|
||||
.right_from(state.ids.resolution, 8.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.bit_depth_label, ui);
|
||||
@ -1396,7 +1446,7 @@ impl<'a> Widget for Video<'a> {
|
||||
Text::new(self.localized_strings.get("hud.settings.refresh_rate"))
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.down_from(state.ids.particles_label, 8.0)
|
||||
.down_from(state.ids.flashing_lights_label, 25.0)
|
||||
.right_from(state.ids.bit_depth, 8.0)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.refresh_rate_label, ui);
|
||||
|
@ -352,6 +352,8 @@ pub struct RenderMode {
|
||||
/// 0.0..1.0
|
||||
pub point_glow: f32,
|
||||
|
||||
pub flashing_lights_enabled: bool,
|
||||
|
||||
pub experimental_shaders: HashSet<ExperimentalShader>,
|
||||
|
||||
pub upscale_mode: UpscaleMode,
|
||||
@ -370,6 +372,7 @@ impl Default for RenderMode {
|
||||
rain_occlusion: ShadowMapMode::default(),
|
||||
bloom: BloomMode::default(),
|
||||
point_glow: 0.35,
|
||||
flashing_lights_enabled: true,
|
||||
experimental_shaders: HashSet::default(),
|
||||
upscale_mode: UpscaleMode::default(),
|
||||
present_mode: PresentMode::default(),
|
||||
@ -390,6 +393,7 @@ impl RenderMode {
|
||||
rain_occlusion: self.rain_occlusion,
|
||||
bloom: self.bloom,
|
||||
point_glow: self.point_glow,
|
||||
flashing_lights_enabled: self.flashing_lights_enabled,
|
||||
experimental_shaders: self.experimental_shaders,
|
||||
},
|
||||
OtherModes {
|
||||
@ -413,6 +417,7 @@ pub struct PipelineModes {
|
||||
pub rain_occlusion: ShadowMapMode,
|
||||
bloom: BloomMode,
|
||||
point_glow: f32,
|
||||
flashing_lights_enabled: bool,
|
||||
experimental_shaders: HashSet<ExperimentalShader>,
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,10 @@ impl ShaderModules {
|
||||
);
|
||||
}
|
||||
|
||||
if pipeline_modes.flashing_lights_enabled {
|
||||
constants += "#define FLASHING_LIGHTS_ENABLED";
|
||||
}
|
||||
|
||||
for shader in pipeline_modes.experimental_shaders.iter() {
|
||||
constants += &format!(
|
||||
"#define EXPERIMENTAL_{}\n",
|
||||
|
@ -126,6 +126,7 @@ pub struct SceneData<'a> {
|
||||
pub sprite_render_distance: f32,
|
||||
pub particles_enabled: bool,
|
||||
pub weapon_trails_enabled: bool,
|
||||
pub flashing_lights_enabled: bool,
|
||||
pub figure_lod_render_distance: f32,
|
||||
pub is_aiming: bool,
|
||||
}
|
||||
|
@ -787,11 +787,13 @@ impl ParticleMgr {
|
||||
let (from, to) = (Vec3::<f32>::unit_z(), *ori.look_dir());
|
||||
let m = Mat3::<f32>::rotation_from_to_3d(from, to);
|
||||
// Emit a light when using flames
|
||||
lights.push(Light::new(
|
||||
pos,
|
||||
Rgb::new(1.0, 0.25, 0.05).map(|e| e * rng.gen_range(0.8..1.2)),
|
||||
2.0,
|
||||
));
|
||||
if scene_data.flashing_lights_enabled {
|
||||
lights.push(Light::new(
|
||||
pos,
|
||||
Rgb::new(1.0, 0.25, 0.05).map(|e| e * rng.gen_range(0.8..1.2)),
|
||||
2.0,
|
||||
));
|
||||
}
|
||||
self.particles.resize_with(
|
||||
self.particles.len() + usize::from(beam_tick_count) / 2,
|
||||
|| {
|
||||
@ -818,11 +820,13 @@ impl ParticleMgr {
|
||||
let (from, to) = (Vec3::<f32>::unit_z(), *ori.look_dir());
|
||||
let m = Mat3::<f32>::rotation_from_to_3d(from, to);
|
||||
// Emit a light when using flames
|
||||
lights.push(Light::new(
|
||||
pos,
|
||||
Rgb::new(1.0, 0.0, 1.0).map(|e| e * rng.gen_range(0.5..1.0)),
|
||||
2.0,
|
||||
));
|
||||
if scene_data.flashing_lights_enabled {
|
||||
lights.push(Light::new(
|
||||
pos,
|
||||
Rgb::new(1.0, 0.0, 1.0).map(|e| e * rng.gen_range(0.5..1.0)),
|
||||
2.0,
|
||||
));
|
||||
}
|
||||
self.particles.resize_with(
|
||||
self.particles.len() + usize::from(beam_tick_count) / 2,
|
||||
|| {
|
||||
@ -846,7 +850,9 @@ impl ParticleMgr {
|
||||
},
|
||||
beam::FrontendSpecifier::LifestealBeam => {
|
||||
// Emit a light when using lifesteal beam
|
||||
lights.push(Light::new(pos, Rgb::new(0.8, 1.0, 0.5), 1.0));
|
||||
if scene_data.flashing_lights_enabled {
|
||||
lights.push(Light::new(pos, Rgb::new(0.8, 1.0, 0.5), 1.0));
|
||||
}
|
||||
self.particles.reserve(beam_tick_count as usize);
|
||||
for i in 0..beam_tick_count {
|
||||
self.particles.push(Particle::new_directed(
|
||||
|
@ -1593,6 +1593,11 @@ impl PlayState for SessionState {
|
||||
as f32,
|
||||
particles_enabled: global_state.settings.graphics.particles_enabled,
|
||||
weapon_trails_enabled: global_state.settings.graphics.weapon_trails_enabled,
|
||||
flashing_lights_enabled: global_state
|
||||
.settings
|
||||
.graphics
|
||||
.render_mode
|
||||
.flashing_lights_enabled,
|
||||
figure_lod_render_distance: global_state
|
||||
.settings
|
||||
.graphics
|
||||
@ -1671,6 +1676,7 @@ impl PlayState for SessionState {
|
||||
figure_lod_render_distance: settings.graphics.figure_lod_render_distance as f32,
|
||||
particles_enabled: settings.graphics.particles_enabled,
|
||||
weapon_trails_enabled: settings.graphics.weapon_trails_enabled,
|
||||
flashing_lights_enabled: settings.graphics.render_mode.flashing_lights_enabled,
|
||||
is_aiming: self.is_aiming,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user