feat(lighting): add ambient light

This commit is contained in:
Kristofers Solo 2024-10-25 17:22:37 +03:00
parent c471382f6f
commit 07794aa993
6 changed files with 38 additions and 67 deletions

72
Cargo.lock generated
View File

@ -188,7 +188,7 @@ checksum = "df099ccb16cd014ff054ac1bf392c67feeef57164b05c42f037cd40f5d4357f4"
dependencies = [ dependencies = [
"clipboard-win", "clipboard-win",
"core-graphics", "core-graphics",
"image 0.25.2", "image",
"log", "log",
"objc2", "objc2",
"objc2-app-kit", "objc2-app-kit",
@ -324,9 +324,9 @@ dependencies = [
[[package]] [[package]]
name = "bevy-inspector-egui" name = "bevy-inspector-egui"
version = "0.26.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d46ba955761969dbc9a79d3583a175609b4e370303bc0f9a5846397dcb7f05fd" checksum = "cac12a22e5de801323bc5bc344949de086b9b8db02c34e109f128ffd41514e5d"
dependencies = [ dependencies = [
"bevy-inspector-egui-derive", "bevy-inspector-egui-derive",
"bevy_app", "bevy_app",
@ -349,17 +349,17 @@ dependencies = [
"bytemuck", "bytemuck",
"egui", "egui",
"fuzzy-matcher", "fuzzy-matcher",
"image 0.24.9", "image",
"once_cell",
"pretty-type-name", "pretty-type-name",
"smallvec", "smallvec",
"winit",
] ]
[[package]] [[package]]
name = "bevy-inspector-egui-derive" name = "bevy-inspector-egui-derive"
version = "0.26.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06683f27065a27065ef8cebe77d7b347c9d0511a091deafd6dd77c5535434934" checksum = "89f3be3ba88a25445c0c10684709b1ccd07e37f5f6b5d1b8dcf11d34548f1d61"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -643,14 +643,13 @@ dependencies = [
[[package]] [[package]]
name = "bevy_egui" name = "bevy_egui"
version = "0.29.0" version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "128438a8163e49528207aabf20d3ff0890fd6be0f0054626915995efac87922b" checksum = "d0b8c164da1303ac3e6dc8d1a649be3e4399f12fd132f7665f3d018884236f9c"
dependencies = [ dependencies = [
"arboard", "arboard",
"bevy", "bevy",
"bytemuck", "bytemuck",
"console_log",
"crossbeam-channel", "crossbeam-channel",
"egui", "egui",
"js-sys", "js-sys",
@ -986,7 +985,7 @@ dependencies = [
"encase", "encase",
"futures-lite", "futures-lite",
"hexasphere", "hexasphere",
"image 0.25.2", "image",
"js-sys", "js-sys",
"ktx2", "ktx2",
"naga", "naga",
@ -1484,12 +1483,6 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]] [[package]]
name = "com" name = "com"
version = "0.6.0" version = "0.6.0"
@ -1550,16 +1543,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "console_log"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f"
dependencies = [
"log",
"web-sys",
]
[[package]] [[package]]
name = "const-fnv1a-hash" name = "const-fnv1a-hash"
version = "1.1.0" version = "1.1.0"
@ -1777,9 +1760,9 @@ checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
[[package]] [[package]]
name = "ecolor" name = "ecolor"
version = "0.28.1" version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e6b451ff1143f6de0f33fc7f1b68fecfd2c7de06e104de96c4514de3f5396f8" checksum = "775cfde491852059e386c4e1deb4aef381c617dc364184c6f6afee99b87c402b"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"emath", "emath",
@ -1787,9 +1770,9 @@ dependencies = [
[[package]] [[package]]
name = "egui" name = "egui"
version = "0.28.1" version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20c97e70a2768de630f161bb5392cbd3874fcf72868f14df0e002e82e06cb798" checksum = "53eafabcce0cb2325a59a98736efe0bf060585b437763f8c476957fb274bb974"
dependencies = [ dependencies = [
"ahash", "ahash",
"emath", "emath",
@ -1805,9 +1788,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]] [[package]]
name = "emath" name = "emath"
version = "0.28.1" version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a6a21708405ea88f63d8309650b4d77431f4bc28fb9d8e6f77d3963b51249e6" checksum = "b1fe0049ce51d0fb414d029e668dd72eb30bc2b739bf34296ed97bd33df544f3"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
] ]
@ -1846,19 +1829,26 @@ dependencies = [
[[package]] [[package]]
name = "epaint" name = "epaint"
version = "0.28.1" version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f0dcc0a0771e7500e94cd1cb797bd13c9f23b9409bdc3c824e2cbc562b7fa01" checksum = "a32af8da821bd4f43f2c137e295459ee2e1661d87ca8779dfa0eaf45d870e20f"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"ahash", "ahash",
"bytemuck", "bytemuck",
"ecolor", "ecolor",
"emath", "emath",
"epaint_default_fonts",
"nohash-hasher", "nohash-hasher",
"parking_lot", "parking_lot",
] ]
[[package]]
name = "epaint_default_fonts"
version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "483440db0b7993cf77a20314f08311dbe95675092405518c0677aa08c151a3ea"
[[package]] [[package]]
name = "equivalent" name = "equivalent"
version = "1.0.1" version = "1.0.1"
@ -2375,18 +2365,6 @@ dependencies = [
"unicode-normalization", "unicode-normalization",
] ]
[[package]]
name = "image"
version = "0.24.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d"
dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"num-traits",
]
[[package]] [[package]]
name = "image" name = "image"
version = "0.25.2" version = "0.25.2"

View File

@ -19,7 +19,7 @@ tracing = { version = "0.1", features = [
] } ] }
hexx = { version = "0.18", features = ["bevy_reflect", "grid"] } hexx = { version = "0.18", features = ["bevy_reflect", "grid"] }
bevy_prototype_lyon = "0.12" bevy_prototype_lyon = "0.12"
bevy-inspector-egui = { version = "0.26", optional = true } bevy-inspector-egui = { version = "0.27", optional = true }
[features] [features]

View File

@ -51,7 +51,7 @@ impl Plugin for AppPlugin {
}) })
.set(AudioPlugin { .set(AudioPlugin {
global_volume: GlobalVolume { global_volume: GlobalVolume {
volume: Volume::new(0.3), volume: Volume::new(0.),
}, },
..default() ..default()
}), }),
@ -91,7 +91,7 @@ fn spawn_camera(mut commands: Commands) {
commands.spawn(( commands.spawn((
Name::new("Camera"), Name::new("Camera"),
Camera3dBundle { Camera3dBundle {
transform: Transform::from_xyz(0., 100., 0.).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(0., 100., 100.).looking_at(Vec3::ZERO, Vec3::Y),
..default() ..default()
}, },
// Render all UI to this camera. // Render all UI to this camera.

View File

@ -1,5 +1,6 @@
use bevy::{ use bevy::{
ecs::{system::RunSystemOnce, world::Command}, ecs::{system::RunSystemOnce, world::Command},
pbr::wireframe::WireframePlugin,
prelude::*, prelude::*,
}; };
@ -12,6 +13,10 @@ impl Plugin for MazePlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_plugins(prism::plugin); app.add_plugins(prism::plugin);
app.add_plugins(grid::plugin); app.add_plugins(grid::plugin);
app.insert_resource(AmbientLight {
brightness: f32::MAX,
color: Color::WHITE,
});
} }
} }

View File

@ -1,4 +1,4 @@
use bevy::prelude::*; use bevy::{pbr::wireframe::Wireframe, prelude::*};
use std::f32::consts::FRAC_PI_2; use std::f32::consts::FRAC_PI_2;
use super::{ use super::{
@ -6,19 +6,7 @@ use super::{
tile::Tile, tile::Tile,
}; };
pub(super) fn plugin(app: &mut App) { pub(super) fn plugin(_app: &mut App) {}
app.add_systems(Startup, spawn_light);
}
pub(super) fn spawn_light(mut commands: Commands) {
commands.spawn((
Name::new("Light Source"),
PointLightBundle {
transform: Transform::from_xyz(0., 50., 0.),
..default()
},
));
}
pub(super) fn setup( pub(super) fn setup(
mut commands: Commands, mut commands: Commands,

View File

@ -15,7 +15,7 @@ pub struct MazeConfig {
impl Default for MazeConfig { impl Default for MazeConfig {
fn default() -> Self { fn default() -> Self {
let mut rng = thread_rng(); let mut rng = thread_rng();
let radius = 5; let radius = 11;
let start_pos = Hex::new( let start_pos = Hex::new(
rng.gen_range(-radius..radius), rng.gen_range(-radius..radius),
rng.gen_range(-radius..radius), rng.gen_range(-radius..radius),
@ -28,8 +28,8 @@ impl Default for MazeConfig {
debug!("End pos: ({},{})", end_pos.x, end_pos.y); debug!("End pos: ({},{})", end_pos.x, end_pos.y);
Self { Self {
radius: radius as u32, radius: radius as u32,
size: 5., size: 1.,
height: 5., height: 15.,
start_pos, start_pos,
end_pos, end_pos,
} }