neopallium / bevy_water Goto Github PK
View Code? Open in Web Editor NEWDynamic ocean material for Bevy.
Home Page: https://neopallium.github.io/bevy_water/
Dynamic ocean material for Bevy.
Home Page: https://neopallium.github.io/bevy_water/
First of, this is a really cool project!
It seems the current state is that only the height of the waves is changeable.
Options that I think are needed:
In a stylized game, the water might be unnaturally colored.
In swamp regions the water should be able to be dirty brown without the ability to see the ground
In tropical regions the water should be able to be a bit more greenish with the ability to be partly transparent
If someone wants to create water with stronger wind, the speed of the waves is at least as important as the height
Wouldn't consider this one strictly needed but I think it would be nice
Hi, I've encountered a rather obscure bug when experimenting with spawning WaterTile
s manually in my game.
In short, if a WaterTile
is spawned after startup and the camera has TAA added (TemporalAntiAliasBundle
), the water shader doesn't work correctly.
I've uploaded an example repo here which has 3 modes:
enum Mode {
/// Use bevy_water's default plugin so water spawns automatically. TAA enabled.
WaterPlugin,
/// Press 'E' to spawn water manually. TAA disabled.
ManualSpawnNoTAA,
/// Press 'E' to spawn water manually. TAA enabled.
ManualSpawnTAA,
}
These look as follows:
The most important fields would be the base_color
, fog and alpha modes.
I have some half finished buoyancy code using bevy_rapier. Do you think that fits in this library when its finished?
I'm somewhat hesitant to add dependencies.
I tried running the ocean
example on desktop and it works perfectly with Bevy 0.10.
Adapter Info:
2023-06-28T14:37:34.618525Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3050 Laptop GPU", vendor: 4318, device: 9634, de
vice_type: DiscreteGpu, driver: "NVIDIA", driver_info: "525.116.04", backend: Vulkan }
2023-06-28T14:37:34.791949Z INFO yogurt_sim::bevy_water::ocean: Move camera around by using WASD for lateral movement
2023-06-28T14:37:34.791972Z INFO yogurt_sim::bevy_water::ocean: Use Left Shift and Spacebar for vertical movement
2023-06-28T14:37:34.791978Z INFO yogurt_sim::bevy_water::ocean: Use the mouse to look around
2023-06-28T14:37:34.791981Z INFO yogurt_sim::bevy_water::ocean: Press Esc to hide or show the mouse cursor
2023-06-28T14:37:34.792265Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 22.04 Pop!_OS", kerne
l: "6.2.6-76060206-generic", cpu: "12th Gen Intel(R) Core(TM) i7-12700H", core_count: "14", memory: "15.5 GiB" }
But when I tried it in wasm using wasm-pack and I got this error:
panicked at 'wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
note: label = `pbr_alpha_blend_mesh_pipeline`
error matching FRAGMENT shader requirements against the pipeline
shader global ResourceBinding { group: 0, binding: 16 } is not available in the layout pipeline layout
binding is missing from the pipeline layout
Here is the log from console for Adapter info:
AdapterInfo { name: "Intel(R) HD Graphics", vendor: 32902, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }
What should I do to get rid of this error ?
A C++ source that could easily be ported is e.g. available as part of the Houdini Ocean Toolkit here:
A nice property of this algorithm is that it outputs parameters that can be used to drive foam (shading) and spray (particles).
Having access to a terrain heightmap would allow:
One can simplify the code by using a custom SystemParam that contains WaterSettings and Time data. This will allow one to access the members directly instead of manually specifying the time and height.
Calling Time
methods repeatedly shouldn't cause any overhead AFAICT.
Whenever water would be rendered I receive the error output below. I have tested having the WaterPlugin
added, but no water to render and there is no errors.
I've also tested this on Windows 11 as well as Pop!_OS 22.04.
This is the simplest version of the code which causes the error.
use bevy::prelude::*;
use bevy_water::{WaterPlugin as BevyWaterPlugin, *};
pub struct WaterPlugin;
impl Plugin for WaterPlugin {
fn build(&self, app: &mut App) {
app
.insert_resource(WaterSettings {
spawn_tiles: Some(UVec2::new(10, 10)),
..default()
})
.add_plugins(BevyWaterPlugin);
}
}
Error Output:
2024-03-23T23:01:51.863351Z INFO bevy_winit::system: Creating new window "Play Koi" (0v1)
2024-03-23T23:01:51.863533Z INFO log: Guessed window scale factor: 1
2024-03-23T23:01:51.896667Z INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon RX 7900 XTX (RADV NAVI31)", vendor: 4098, device: 29772, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 24.0.0-1pop0~1706872735~22.04~0fa430c", backend: Vulkan }
2024-03-23T23:01:52.160780Z INFO log: Gamepad /dev/input/event3 (ASRock LED Controller) connected.
2024-03-23T23:01:52.177643Z INFO bevy_input::gamepad: Gamepad { id: 0 } Connected
2024-03-23T23:01:52.177754Z INFO play_koi::plugins::camera_controller:
2024-03-23T23:01:52.248743Z ERROR log: Device::create_render_pipeline error: Error matching ShaderStages(VERTEX) shader requirements against the pipeline
2024-03-23T23:01:52.248764Z ERROR log: Handling wgpu errors as fatal by default
thread 'Async Compute Task Pool (3)' panicked at /home/achill113/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.3/src/backend/wgpu_core.rs:3006:5:
wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
note: label = `pbr_alpha_blend_mesh_pipeline`
Error matching ShaderStages(VERTEX) shader requirements against the pipeline
Shader global ResourceBinding { group: 0, binding: 9 } is not available in the pipeline layout
Visibility flags don't include the shader stage
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system`!
thread 'Compute Task Pool (1)' panicked at /home/achill113/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.13.0/src/pipelined_rendering.rs:49:67:
called `Result::unwrap()` on an `Err` value: RecvError
Put these in water settings
pub const WATER_SIZE: u32 = 256;
pub const WATER_HALF_SIZE: f32 = WATER_SIZE as f32 / 2.0;
pub const WATER_GRID_SIZE: u32 = 6;
I might be misunderstanding something but shouldn't b
be along the x axis and c
along the y axis?
I am currently developing RTS game. In places with water i encountered FPS drops by 2x. I am using this settings for water:
.insert_resource(WaterSettings {
height: 0.0,
clarity: 0.95,
..default()
})
I'm also using TAA for anti aliasing, CAS and SSAO, but when i turn them off (and add DepthPrepass in place of TAA) drops still ocure.
I currently have RX 7600 (arround RTX 4060 performance)
Hello!
When importing the package I had to copy the shaders into my projects assets
directory.
This seems to be because the shaders are only imported at runtime and bevy uses the environment set up by cargo to infer the correct paths.
Loading the shaders via load_internal_asset
worked for me.
thread 'main' panicked at /home/andy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_asset-0.13.1/src/reflect.rs:159:36:
Requested resource bevy_asset::assets::Assets<bevy_water::water::material::WaterMaterial> does not exist in the `World`.
Did you forget to add it using `app.insert_resource` / `app.init_resource`?
Resources are also implicitly added via `app.add_event`,
and can be added by plugins.
stack backtrace:
0: rust_begin_unwind
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: bevy_ecs::world::World::resource
at /home/andy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.13.1/src/world/mod.rs:1295:21
3: <bevy_asset::reflect::ReflectAsset as bevy_reflect::type_registry::FromType<A>>::from_type::{{closure}}
at /home/andy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_asset-0.13.1/src/reflect.rs:159:30
4: core::ops::function::FnOnce::call_once
When my account was compromised a spam issue was created in this repo. I sincerely apologize. Cleaning up such issues via script.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.