| Crates.io | bevy_eulerian_fluid |
| lib.rs | bevy_eulerian_fluid |
| version | 0.3.0 |
| created_at | 2025-01-10 16:33:41.942222+00 |
| updated_at | 2025-11-18 08:55:09.224548+00 |
| description | An eularian fluid simulation plugin for Bevy. |
| homepage | |
| repository | https://github.com/narasan49/bevy_eulerian_fluid |
| max_upload_size | |
| id | 1511453 |
| size | 9,733,293 |
This project is a fluid simulation plugin for Bevy.

Try it on here!
FluidPlugin and PhysicsPlugins to the app with the same length unit.FluidSettings, then FluidSimulationBundle will be inserted automatically to the entity. By querying components bundled with FluidSimulationBundle such as VelocityTextures, the simulation results can be retreived.Here is a short example. See examples for the detailed implementation!
use avian2d::PhysicsPlugins;
use bevy_eulerian_fluid::{
definition::{FluidSettings, LevelsetTextures, VelocityTextures},
FluidPlugin,
};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(FluidPlugin::new(10.0))
.add_plugins(PhysicsPlugins::default().with_length_unit(10.0))
.add_systems(Startup, setup_scene)
.add_systems(Update, on_initialized)
.run();
}
fn setup_scene(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(FluidSettings {
rho: 997f32, // water
gravity: Vec2::Y,
size: UVec2::new(512),
initial_fluid_level: 0.9,
});
}
fn on_initialized(
mut commands: Commands,
query: Query<(Entity, &LevelsetTextures, &VelocityTextures), Added<LevelsetTextures>>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<CustomMaterial>>,
mut velocity_materials: ResMut<Assets<VelocityMaterial>>,
) {
for (entity, levelset_textures, velocity_textures) in &query {
// Implement your own code to visualize the results.
}
}
The simulation entity has LocalForces component, which holds arrays of forces (in m/s^2) and position (in pixels). forces can be applied to the simulation domain by setting LocalForces.
See also an interaction example for the detailed implementation.
There are some examples to demonstrate how to visualize and interact to the simulation results:
Fluid-Solid two-way interaction
cargo run --example various_shapes

Imposing forces with mouse and touch input (Also available here)
cargo run --example interaction

| Bevy | Bevy Eularian Fluid |
|---|---|
| 0.17 | 0.2, 0.3 |
| 0.15 | 0.1 |
The simulation is inspired by and based on the algorithms described in these books:
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.