AR now adds AI-generated fake ambient light to the darkness of space

This commit is contained in:
yuni 2024-03-20 06:55:54 +01:00
parent 3cf3d05b7b
commit a29ab0cc42
2 changed files with 14 additions and 6 deletions

View file

@ -10,6 +10,8 @@ pub const FONT: &str = "external/NotoSansSC-Thin.ttf";
pub const LOG_MAX: usize = 20;
pub const LOG_MAX_TIME_S: u64 = 20;
pub const CHOICE_NONE: &str = "";
pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK
pub const AMBIENT_LIGHT_AR: f32 = 20.0;
pub struct HudPlugin;
impl Plugin for HudPlugin {
@ -106,6 +108,7 @@ fn setup(
settings: Res<settings::Settings>,
asset_server: Res<AssetServer>,
mut log: ResMut<Log>,
mut ambient_light: ResMut<AmbientLight>,
) {
log.info("Customer wake-up registered.".to_string());
log.info("Systems reactivated.".to_string());
@ -299,6 +302,13 @@ fn setup(
ChatText,
));
});
// AR-related things
ambient_light.brightness = if settings.hud_active {
AMBIENT_LIGHT_AR
} else {
AMBIENT_LIGHT
};
}
fn update(
@ -342,7 +352,7 @@ fn update(
let mut choices: Vec<String> = Vec::new();
let mut count = 1;
for choice in &q_choices {
choices.push(format!("[{}. @{}: {}]",
choices.push(format!("[{}] @{}: {}",
count, choice.recipient, choice.text));
count += 1;
}
@ -377,6 +387,7 @@ fn handle_input(
mut evwriter_sfx: EventWriter<audio::PlaySfxEvent>,
mut evwriter_togglemusic: EventWriter<audio::ToggleMusicEvent>,
q_choices: Query<&ChoiceAvailable>,
mut ambient_light: ResMut<AmbientLight>,
) {
if keyboard_input.just_pressed(settings.key_togglehud) {
if let Ok(mut vis) = query.get_single_mut() {
@ -384,10 +395,12 @@ fn handle_input(
if *vis == Visibility::Inherited {
*vis = Visibility::Hidden;
settings.hud_active = false;
ambient_light.brightness = AMBIENT_LIGHT;
bloomsettings.composite_mode = BloomCompositeMode::EnergyConserving;
} else {
*vis = Visibility::Inherited;
settings.hud_active = true;
ambient_light.brightness = AMBIENT_LIGHT_AR;
bloomsettings.composite_mode = BloomCompositeMode::EnergyConserving;
//bloomsettings.composite_mode = BloomCompositeMode::Additive;
}

View file

@ -61,8 +61,6 @@ pub fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut ambient_light: ResMut<AmbientLight>,
// settings: Res<settings::Settings>,
asset_server: Res<AssetServer>,
) {
// let cubemap_handle = asset_server.load(ASSET_CUBEMAP);
@ -293,9 +291,6 @@ pub fn setup(
},
));
// Space is DARK
ambient_light.brightness = 0.0;
// Add Light from the Sun
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {