Very small quality of life stuff, broke shadows

Click to move through into + title
Speed up animations by pressing down instead of jumping to end.
    (tweakable)
main
Elijah C. Voigt 2 years ago
parent 9f5856f86f
commit 95559d8887

@ -149,6 +149,21 @@ put_down = "/SFX/3D/3DPutDownPiece"
idle = "/SFX/3D/3DPickup-Idle-PutdownWhirr"
invalid = "/sfx/3D/3DInvalidMove"
####################
# Color Settings
####################
[color.grading]
exposure = 1.1
gamma = 1.1
pre_saturation = 1.0
post_saturation = 1.0
[color.fog]
density = 0.0025
[color.bloom]
intensity = 0.1
####################
# Display3d settings
####################
@ -206,3 +221,10 @@ drone_blue = "DroneBluePieceIdle"
drone_red = "DroneRedPieceIdle"
queen_blue = "QueenBluePieceIdle"
queen_red = "QueenRedPieceIdle"
######################
### Animation Settings
######################
[animation]
fast_speed = 2.0

BIN
assets/models/Martian Chess.glb (Stored with Git LFS)

Binary file not shown.

@ -1,5 +1,5 @@
use bevy::core_pipeline::{
bloom::{BloomCompositeMode, BloomPrefilterSettings}, contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, experimental::taa::TemporalAntiAliasBundle, fxaa::{Fxaa, FxaaPlugin, Sensitivity}
contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, fxaa::Fxaa
};
use crate::prelude::*;
@ -25,6 +25,21 @@ impl Plugin for Display3dPlugin {
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
),
)
// Systems related to color and camera
.add_systems(
Update,
(
color_grading_tweak
.run_if(resource_exists::<tweak::GameTweaks>)
.run_if(on_event::<AssetEvent<Tweaks>>()),
fog_tweak
.run_if(resource_exists::<tweak::GameTweaks>)
.run_if(on_event::<AssetEvent<Tweaks>>()),
bloom_tweak
.run_if(resource_exists::<tweak::GameTweaks>)
.run_if(on_event::<AssetEvent<Tweaks>>()),
)
)
.add_systems(
Update,
(
@ -41,6 +56,7 @@ impl Plugin for Display3dPlugin {
.run_if(state_changed::<game::TurnState>),
update_pieces
.run_if(resource_exists::<tweak::GameTweaks>)
.run_if(in_state(GameState::Play))
.run_if(
any_component_changed::<Piece>()
.or_else(any_component_changed::<Side>())
@ -66,7 +82,10 @@ impl Plugin for Display3dPlugin {
capture_piece.run_if(any_with_component::<game::Captured>),
skip_animation
.run_if(in_state(GameState::Play))
.run_if(just_pressed(KeyCode::Enter).or_else(just_pressed(MouseButton::Left))),
.run_if(pressed(KeyCode::Enter).or_else(pressed(MouseButton::Left))),
un_skip_animation
.run_if(in_state(GameState::Play))
.run_if(just_released(KeyCode::Enter).or_else(just_released(MouseButton::Left))),
monitor_animations
.run_if(in_state(GameState::Play))
.run_if(any_component_changed::<AnimationPlayer>()),
@ -91,23 +110,28 @@ impl Plugin for Display3dPlugin {
(
// Toggle hidden/visible 3d entities
manage_state_entities::<DisplayState>(),
fixup_shadows,
// fixup_shadows,
color_grading_tweak
.run_if(resource_exists::<tweak::GameTweaks>),
fog_tweak
.run_if(resource_exists::<tweak::GameTweaks>),
bloom_tweak
.run_if(resource_exists::<tweak::GameTweaks>),
update_pieces.run_if(resource_exists::<tweak::GameTweaks>),
),
)
.add_systems(
OnEnter(GameState::Play),
(
update_pieces.run_if(resource_exists::<tweak::GameTweaks>),
update_tweaks.run_if(resource_exists::<tweak::GameTweaks>),
opening_animation
.run_if(run_once())
.run_if(in_state(DisplayState::Display3d)),
fixup_shadows.after(update_pieces),
),
)
.add_systems(OnEnter(GameState::Title), (
intro_title_dissolve,
fixup_shadows,
intro_title_dissolve,
))
.add_systems(OnExit(GameState::Title), outro_title_dissolve)
.add_systems(
@ -327,22 +351,16 @@ fn hydrate_camera(
..default()
},
BloomSettings {
intensity: 0.05,
prefilter_settings: BloomPrefilterSettings {
threshold: 0.8,
threshold_softness: 0.5,
},
composite_mode: BloomCompositeMode::Additive,
intensity: 0.0,
..default()
},
FogSettings {
color: Color::rgba(0.25, 0.25, 0.25, 1.0),
falloff: FogFalloff::Exponential {
density: 0.025,
density: 0.0,
},
..default()
},
// ScreenSpaceAmbientOcclusionBundle { ..default() },
));
let assets_handle = tweak
@ -376,7 +394,7 @@ fn hydrate_camera(
/// Update display3d tweaks in the game
/// Triggered on entering 3d state and when the tweakfile is updated.
fn update_tweaks(
mut camera_settings: Query<(Entity, &mut Skybox, &mut EnvironmentMapLight), With<Display3d>>,
mut camera_settings: Query<(&mut Skybox, &mut EnvironmentMapLight), With<Display3d>>,
tweaks_file: Res<tweak::GameTweaks>,
tweaks: Res<Assets<Tweaks>>,
) {
@ -384,7 +402,7 @@ fn update_tweaks(
warn!("Updating tweaks!");
camera_settings
.iter_mut()
.for_each(|(entity, mut skybox, mut environment_map_light)| {
.for_each(|(mut skybox, mut environment_map_light)| {
skybox.brightness = tweak.get::<f32>("display3d_skybox_brightness").unwrap();
environment_map_light.intensity = tweak
.get::<f32>("display3d_environment_map_light_intensity")
@ -924,17 +942,27 @@ fn opening_animation(mut players: Query<&mut AnimationPlayer, (With<Camera>, Wit
// When called skips any running animations
fn skip_animation(
mut players: Query<&mut AnimationPlayer>,
clips: Res<Assets<AnimationClip>>,
time: Res<Time>,
mut players: Query<&mut AnimationPlayer, With<Animating>>,
tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>,
) {
let tweak = tweaks
.get(tweaks_file.handle.clone())
.expect("Load tweakfile");
let speed = tweak.get::<f32>("animation_fast_speed").unwrap();
players.iter_mut().for_each(|mut p| {
if let Some(c) = clips.get(p.animation_clip()) {
info!("Skipping animation");
// HACK: We should be able to skip to the end of an animation
// But implementation details means this is as close as we can get...
p.seek_to(c.duration() - (2.0 * time.delta_seconds()));
debug!("Skipping animation");
// HACK: Set the speed of the animation to turbo
p.set_speed(speed);
})
}
fn un_skip_animation(
mut players: Query<&mut AnimationPlayer, With<Animating>>,
) {
players.iter_mut().for_each(|mut p| {
debug!("Un-Skipping animation");
p.set_speed(1.0);
})
}
@ -1151,7 +1179,7 @@ struct Animating;
fn monitor_animations(
active: Query<(Entity, &AnimationPlayer), (Changed<AnimationPlayer>, With<Animating>)>,
inactive: Query<(Entity, &AnimationPlayer), (Changed<AnimationPlayer>, Without<Animating>)>,
mut inactive: Query<(Entity, &mut AnimationPlayer), (Changed<AnimationPlayer>, Without<Animating>)>,
mut commands: Commands,
) {
// Remove Animating component from players that are done
@ -1162,10 +1190,11 @@ fn monitor_animations(
}
});
// Set inactive entities to active
inactive.iter().for_each(|(entity, player)| {
inactive.iter_mut().for_each(|(entity, mut player)| {
if !player.is_finished() && *player.animation_clip() != Handle::<AnimationClip>::default() {
info!("Entity {:?} is playing {:?}, adding animating marker", entity, player.animation_clip());
commands.entity(entity).insert(Animating);
player.set_speed(1.0);
}
});
}
@ -1207,6 +1236,8 @@ fn dissolve_animation(
mut dissolve_materials: ResMut<Assets<DissolveMaterial>>,
object_materials: Query<(Entity, &Handle<DissolveMaterial>)>,
mut commands: Commands,
keys: Res<ButtonInput<KeyCode>>,
mouse: Res<ButtonInput<MouseButton>>,
time: Res<Time>,
) {
query
@ -1214,8 +1245,13 @@ fn dissolve_animation(
.for_each(|(entity, dissolvable, mut dissolving)| {
debug!("Entity {:?} has Dissolving {:?}", entity, dissolving);
let skip = keys.just_pressed(KeyCode::Enter) || mouse.just_pressed(MouseButton::Left);
let percentage = match *dissolving {
Dissolving::In(mut sec) => {
if skip {
1.0
} else {
// Check if seconds is below 0.0
sec = (sec - time.delta_seconds()).max(0.0);
@ -1224,7 +1260,11 @@ fn dissolve_animation(
// Calculate the target percentage value
1.0 - (sec / dissolvable.duration)
}
}
Dissolving::Out(mut sec) => {
if skip {
0.0
} else {
// Check if seconds is below 0.0
sec = (sec - time.delta_seconds()).max(0.0);
@ -1233,6 +1273,7 @@ fn dissolve_animation(
// Calculate the target percentage value
sec / dissolvable.duration
}
}
};
object_materials
@ -1273,3 +1314,54 @@ fn fixup_shadows(
l.shadows_enabled = true;
});
}
fn color_grading_tweak(
mut query: Query<&mut ColorGrading>,
tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>,
) {
let tweak = tweaks
.get(tweaks_file.handle.clone())
.expect("Load tweakfile");
let exposure = tweak.get::<f32>("color_grading_exposure").unwrap();
let gamma = tweak.get::<f32>("color_grading_gamma").unwrap();
let pre_saturation = tweak.get::<f32>("color_grading_pre_saturation").unwrap();
let post_saturation = tweak.get::<f32>("color_grading_post_saturation").unwrap();
query.iter_mut().for_each(|mut cg| {
*cg = ColorGrading {
exposure, gamma, pre_saturation, post_saturation
}
})
}
fn fog_tweak(
mut query: Query<&mut FogSettings>,
tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>,
) {
query.iter_mut().for_each(|mut fog| {
let tweak = tweaks
.get(tweaks_file.handle.clone())
.expect("Load tweakfile");
fog.falloff = FogFalloff::Exponential {
density: tweak.get::<f32>("color_fog_density").unwrap(),
};
})
}
fn bloom_tweak(
mut query: Query<&mut BloomSettings>,
tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>,
) {
query.iter_mut().for_each(|mut bloom| {
let tweak = tweaks
.get(tweaks_file.handle.clone())
.expect("Load tweakfile");
bloom.intensity = tweak.get::<f32>("color_bloom_intensity").unwrap();
})
}

@ -167,3 +167,17 @@ where
{
Box::new(move |buttons: Res<ButtonInput<T>>| -> bool { buttons.just_pressed(button) })
}
pub(crate) fn just_released<T>(button: T) -> impl FnMut(Res<ButtonInput<T>>) -> bool + Clone
where
T: Copy + Eq + Hash + Send + Sync + 'static,
{
Box::new(move |buttons: Res<ButtonInput<T>>| -> bool { buttons.just_released(button) })
}
pub(crate) fn pressed<T>(button: T) -> impl FnMut(Res<ButtonInput<T>>) -> bool + Clone
where
T: Copy + Eq + Hash + Send + Sync + 'static,
{
Box::new(move |buttons: Res<ButtonInput<T>>| -> bool { buttons.pressed(button) })
}

@ -7,8 +7,7 @@ pub(crate) use bevy::{
core::FrameCount,
core_pipeline::{
bloom::BloomSettings,
experimental::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasSettings},
prepass::MotionVectorPrepass,
experimental::taa::TemporalAntiAliasPlugin,
tonemapping::{DebandDither, Tonemapping},
Skybox,
},

Loading…
Cancel
Save