From 0c81742f1132797072a9ef32c41c72027adee9f4 Mon Sep 17 00:00:00 2001 From: Amatsugu Date: Sun, 8 Sep 2024 01:42:13 -0400 Subject: [PATCH] improved water shader --- Cargo.lock | 131 +++++++++++++++++- game/main/Cargo.toml | 2 +- game/main/assets | 2 +- game/main/src/map_rendering/map_init.rs | 7 +- .../src/shader_extensions/water_material.rs | 6 +- game/main/src/utlis/editor_plugin.rs | 4 +- 6 files changed, 141 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e4f008c..b0a287b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -509,6 +509,7 @@ dependencies = [ "futures-io", "futures-lite", "js-sys", + "notify-debouncer-full", "parking_lot", "ron", "serde", @@ -2101,6 +2102,27 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "file-id" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6584280525fb2059cba3db2c04abf947a1a29a45ddae89f3870f8281704fafc9" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox 0.1.3", + "windows-sys 0.59.0", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -2174,6 +2196,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + [[package]] name = "futures-core" version = "0.3.30" @@ -2286,7 +2317,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb5e8d912059b33b463831c16b838d15c4772d584ce332e4a80f6dffdae2bc1" dependencies = [ "core-foundation", - "inotify", + "inotify 0.10.2", "io-kit-sys", "js-sys", "libc", @@ -2623,6 +2654,17 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" +[[package]] +name = "inotify" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" +dependencies = [ + "bitflags 1.3.2", + "inotify-sys", + "libc", +] + [[package]] name = "inotify" version = "0.10.2" @@ -2752,6 +2794,26 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" +[[package]] +name = "kqueue" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "ktx2" version = "0.3.0" @@ -2844,6 +2906,17 @@ dependencies = [ "redox_syscall 0.4.1", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall 0.5.2", +] + [[package]] name = "libudev-sys" version = "0.1.4" @@ -2996,6 +3069,18 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", +] + [[package]] name = "naga" version = "0.20.0" @@ -3187,6 +3272,39 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" +[[package]] +name = "notify" +version = "6.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" +dependencies = [ + "bitflags 2.6.0", + "crossbeam-channel", + "filetime", + "fsevent-sys", + "inotify 0.9.6", + "kqueue", + "libc", + "log", + "mio", + "walkdir", + "windows-sys 0.48.0", +] + +[[package]] +name = "notify-debouncer-full" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f5dab59c348b9b50cf7f261960a20e389feb2713636399cd9082cd4b536154" +dependencies = [ + "crossbeam-channel", + "file-id", + "log", + "notify", + "parking_lot", + "walkdir", +] + [[package]] name = "ntapi" version = "0.4.1" @@ -3543,7 +3661,7 @@ version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166" dependencies = [ - "libredox", + "libredox 0.0.2", ] [[package]] @@ -5468,6 +5586,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.42.2" diff --git a/game/main/Cargo.toml b/game/main/Cargo.toml index 15d5ae0..a2937fc 100644 --- a/game/main/Cargo.toml +++ b/game/main/Cargo.toml @@ -7,7 +7,7 @@ build = "build.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = "0.14.0" +bevy = { version = "0.14.0", features = ["file_watcher"] } bevy-inspector-egui = "0.25.0" iyes_perf_ui = "0.3.0" noise = "0.8.2" diff --git a/game/main/assets b/game/main/assets index 5e5c821..d9e7ec8 160000 --- a/game/main/assets +++ b/game/main/assets @@ -1 +1 @@ -Subproject commit 5e5c821eb152f2f035415a17734d252dba7aed05 +Subproject commit d9e7ec829774a4199a07faeb183662d8222c4f21 diff --git a/game/main/src/map_rendering/map_init.rs b/game/main/src/map_rendering/map_init.rs index dae29fc..3de9084 100644 --- a/game/main/src/map_rendering/map_init.rs +++ b/game/main/src/map_rendering/map_init.rs @@ -105,14 +105,15 @@ fn setup_materials( ) { let water_material = water_materials.add(ExtendedMaterial { base: StandardMaterial { - base_color: Color::srgba(0., 0.5, 1., 0.8), + base_color: Color::srgb(0., 0.878, 1.), alpha_mode: AlphaMode::Blend, ..Default::default() }, extension: WaterMaterial { settings: WaterSettings { - offset: 0.5, - scale: 100., + offset: -4.97, + scale: 1., + deep_color: LinearRgba::rgb(0.0, 0.04, 0.085).into(), ..Default::default() }, ..default() diff --git a/game/main/src/shader_extensions/water_material.rs b/game/main/src/shader_extensions/water_material.rs index 4bcc70e..10db5c0 100644 --- a/game/main/src/shader_extensions/water_material.rs +++ b/game/main/src/shader_extensions/water_material.rs @@ -15,7 +15,8 @@ pub struct WaterMaterial { pub struct WaterSettings { pub offset: f32, pub scale: f32, - pub deep_color: Vec3, + pub f_power: f32, + pub deep_color: LinearRgba, } impl Default for WaterSettings { @@ -23,7 +24,8 @@ impl Default for WaterSettings { Self { offset: 0.0, scale: 1.0, - deep_color: Vec3::ZERO, + f_power: 2.0, + deep_color: default(), } } } diff --git a/game/main/src/utlis/editor_plugin.rs b/game/main/src/utlis/editor_plugin.rs index b6dc417..3b04561 100644 --- a/game/main/src/utlis/editor_plugin.rs +++ b/game/main/src/utlis/editor_plugin.rs @@ -69,8 +69,8 @@ fn asset_reloaded( let mut rebuild = false; for event in asset_events.read() { match event { - AssetEvent::Modified { id } => rebuild = true, - _ => todo!(), + AssetEvent::Modified {..}=> rebuild = true, + _ => (), } } if rebuild {