gpu-nature

DEMO

Running on FireFox Nightly https://jinleili.github.io/gpu-nature.html

gpu-particles.mov

Run on native

cargo run --example {nature|particle}

Run on iOS

Please refer to wgpu-on-app

Run on browser

0th, reprocess shader.

Reasons to handle shaders separately: when running the web environment, wasm-pack will monitor the changes of the .rs file and recompile for hot update, and the build.rs file will generate a new web/generate_shader_map.rs file, which will cause continuous loop compilation.

PREPROCESS_SHADER=true cargo build

First, install Firefox Nightly and enable Web API: WebGPU. Or, install Chrome Canary/Dev and setting: chrome://flags/#enable-unsafe-webgpu

Second, install wasm-pack

# macOS(Intel CPU) or *nix system (Unix, Linux)
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# macOS(M1) or other platforms
cargo install wasm-pack

Third, compile to wasm and start run:

npm install
# only build
RUSTFLAGS=--cfg=web_sys_unstable_apis npm run build
# build then run on browser
RUSTFLAGS=--cfg=web_sys_unstable_apis npm start

Nhat-Phuong Tran, Myungho Lee, and Sugwon Hong, "Performance Optimization of 3D Lattice Boltzmann Flow Solver on a GPU", Scientific Programming, 2017.

Martin Bauer, Ulrich Rüde, "An improved lattice Boltzmann D3Q19 method based on an alternative equilibrium discretization", arXiv preprint arXiv:1803.04937, 2018.

License

Released under the GPLv3 license.