Andrew-McCall / Boids

Boid Simulation in rust. Rendered using WGSL (WGPU & WINIT)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boids

Description

Boid Simulation

A boid simulation is a simulation of a flock of birds. Each bird is called a boid. Each boid has a set of rules that it follows and calculates.

These rules are:

  • Separation: Boids try to keep a small distance away from other objects (including other boids).
  • Alignment: Boids try to align themselves with nearby boids.
  • Cohesion: Boids try to move towards the center of mass of nearby boids.

There are other rules and variations of these rules, but these are the basic rules. I made add more in the future .

Source: Wikipedia

My implementation

I used Rust, WGpu and Winit. My goal was to learn a lower level graphics API and to further cement my knowledge of Rust. With WGpu and Winit my code should run on every platform that supports Vulkan, Metal or DX12. (I have only tested it on Windows 10.)

Showcase

Here is are some videos I made of the program running (Uploaded to Imgur).

The first is boids without rules, just a slightly drift the to left. Imgur Link One

The second is with rules. Imgur Link Two

The third is the current state of the program with rules and tweaked settings. Imgur Link Three

Short Gif of the current state.

Gif

Improvements

  • 2D fish/bird Model or Texture
  • Multi-threading
  • Quad-Tree / Sin and Cos Caching (Other Optimization)
  • Add more rules
  • Add a GUI / Menu
  • 3D Refactor

How to run / build

Cargo is required to build the project. You can download it here.

cargo run --release

cargo build --release --target=[Your system]

*WASM is not supported currently although the libraries do support it

License

MIT License

About

Boid Simulation in rust. Rendered using WGSL (WGPU & WINIT)


Languages

Language:Rust 95.4%Language:WGSL 4.6%