diff --git a/CHANGELOG.md b/CHANGELOG.md index a0d7a52f0b..9d24d3799b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/voxygen/i18n/en/hud/settings.ron b/assets/voxygen/i18n/en/hud/settings.ron index 93d1656faa..f75e9fe391 100644 --- a/assets/voxygen/i18n/en/hud/settings.ron +++ b/assets/voxygen/i18n/en/hud/settings.ron @@ -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", diff --git a/assets/voxygen/shaders/include/point_glow.glsl b/assets/voxygen/shaders/include/point_glow.glsl index 3ffcdce4ec..8331e2b7ad 100644 --- a/assets/voxygen/shaders/include/point_glow.glsl +++ b/assets/voxygen/shaders/include/point_glow.glsl @@ -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; } diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index c41cbb417b..15efe21f86 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -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 = diff --git a/voxygen/src/hud/settings_window/video.rs b/voxygen/src/hud/settings_window/video.rs index 6667abaa2e..39f03cd744 100644 --- a/voxygen/src/hud/settings_window/video.rs +++ b/voxygen/src/hud/settings_window/video.rs @@ -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); diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 47a31e6184..ebf5bd8d91 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -352,6 +352,8 @@ pub struct RenderMode { /// 0.0..1.0 pub point_glow: f32, + pub flashing_lights_enabled: bool, + pub experimental_shaders: HashSet, 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, } diff --git a/voxygen/src/render/renderer/pipeline_creation.rs b/voxygen/src/render/renderer/pipeline_creation.rs index ac29f6e087..4ffbff967f 100644 --- a/voxygen/src/render/renderer/pipeline_creation.rs +++ b/voxygen/src/render/renderer/pipeline_creation.rs @@ -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", diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index a194856953..bd0c9dd443 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -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, } diff --git a/voxygen/src/scene/particle.rs b/voxygen/src/scene/particle.rs index 551fed1c36..a0739d3e63 100644 --- a/voxygen/src/scene/particle.rs +++ b/voxygen/src/scene/particle.rs @@ -787,11 +787,13 @@ impl ParticleMgr { let (from, to) = (Vec3::::unit_z(), *ori.look_dir()); let m = Mat3::::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::::unit_z(), *ori.look_dir()); let m = Mat3::::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( diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index 3183489b56..7f94784de7 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -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, };