Skip to content

Commit

Permalink
improved water shader
Browse files Browse the repository at this point in the history
  • Loading branch information
Amatsugu committed Sep 8, 2024
1 parent d58570f commit 0c81742
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 11 deletions.
131 changes: 129 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion game/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion game/main/assets
7 changes: 4 additions & 3 deletions game/main/src/map_rendering/map_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 4 additions & 2 deletions game/main/src/shader_extensions/water_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ 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 {
fn default() -> Self {
Self {
offset: 0.0,
scale: 1.0,
deep_color: Vec3::ZERO,
f_power: 2.0,
deep_color: default(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions game/main/src/utlis/editor_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0c81742

Please sign in to comment.