This Week in Bevy

What happened this week in the Bevy Engine ecosystem

Links

Vello, Minecraft Settlements, and destructible planets

2024-08-12

This week we have multiple vello-related projects, some great working group progress, gizmos are seeing more usage, and more.

Bevy Jam 5 voting is finishing up within the next 24 hours. Congrats to all who participated.

Bevy's 4th Birthday happened this weekend with a great post from @cart (Bevy's creator and Project Lead). The post includes a great overview of the last year as well as a call for the community to write their own "Bevy Birthday post" and publish it. One month from now, a followup "Reflecting on Bevy's Fourth Year" rollup post will aggregate these in one place.

FixedUpdate vs Update Schedules

#14600 helps answer the question of "how often should your gameplay logic run?" by adding some new documentation on the FixedUpdate and Update schedules. This can be an important distinction since Update will run once-per-render frame, which can affect behavior when players play your game at different framerates (or varying framerates). FixedUpdate by contrast runs at a steady 64 Hz by default and is where you can put behavior that includes game logic that shouldn't "speed up" at higher framerates.

Adding additional context, the Unofficial Bevy Cheatbook has a section called "Should I put my systems in Update or FixedUpdate?".

Mesh::invert_winding

Winding is the order of the vertices that define a triangle. If you connected a thread to one vertex, it would be the direction you have to "wind" the thread around the rest of the vertices to form a triangle: either Clockwise or Counter-Clockwise. This direction affects what is considered the "front face" of your mesh, which in turn can affect whether the mesh is rendered or not (depending on whether you're viewing the front or back).

#14555 introduces Mesh::invert_winding for inverting the winding on a mesh which can effectively switch the front and back faces without affecting other attributes.

Function registry

#13152 added support for reflecting functions. Now #14098 added a FunctionRegistry similar to the TypeRegistry that already exists, allowing the registering and retrieving of functions.

fn foo() -> i32 {
    123
}

let mut registry = FunctionRegistry::default();
registry.register("my_function", foo);

let function = registry.get_mut("my_function").unwrap();
let value = function.call(ArgList::new()).unwrap().unwrap_owned();
assert_eq!(value.downcast_ref::<i32>(), Some(&123));

2d Depth Buffer

2d depth texture

Depth buffers are effectively grayscale textures you can write to from a fragment shader, where the value of a given pixel describes how far away from the camera that pixel is. wgpu can use this texture to determine whether a pixel should draw in front of another pixel. In a 2d environment, you're typically restricted to having all of a sprite in front of or behind all of another sprite, but with a depth texture you have control of this per-pixel.

#13069 adds a depth buffer to Bevy's 2d processing. The image shown in this section uses custom fragment shaders to simulate a "3d"-like depth control on 2d meshes, allowing one sprite to walk "through" the middle of another.

If you want to take advantage of the depth buffer in a fragment shader, you'll want to use Material2d and write to the frag_depth builtin.

struct FragmentOutput {
   @builtin(frag_depth) depth: f32,
   @location(0) color: vec4<f32>
 }

@fragment
fn fragment(in: MeshVertexOutputCustom) -> FragmentOutput {
    var out: FragmentOutput;
    out.color = vec4(1., 0., 1., 1.);
    out.depth = 0.5;
    return out;
}

bevy_mod_picking: the upstreamening

The bevy_mod_picking upstreaming working group has made significant strides this week with upstreaming the remainder of bevy_picking_core in #14686. Much of this work can be found in the bevy_picking crate but do note that this work isn't yet functional for end-users. More work is still to be done building on top of the already-merged event propagation for observers.

A Curve trait for general interoperation — Part I

The Curve Crew working group is also making progress with #14630 implementing part of the Curve RFC.

Part 2 is already up for review.

Skins

Skins are the data that tells a bone which vertices it should be deforming when moved. #14343 makes this data available to users in a way that enables skinned mesh creation without spawning a scene.


Alice's Merge Train is a maintainer-level view into active PRs, both those that are merging and those that need work.

Showcase

Bevy work from the #showcase channel in Discord and around the internet. Use hashtag #bevyengine.

drag and dropdrag and drop

Jarl: Drag and Drop

showcase

Jarl added drag and drop inventory space using Bevy UI.

openstreetmap gizmos

OpenStreetMap with Gizmos

showcase

This is OpenStreetMap data pulled into Bevy and rendered with gizmos in anticipation of a large scale city simulation game.

2d space game2d space game2d space game

2d space game

showcase

2D space game experimenting with making a destructible polygon system for smashing asteroids (voronoi and lloyd relaxation to decompose polys). This is built on Avian physics, and Lightyear networking although this showcase is a local only testbed.

space grid gamespace grid game

Space Grid Game Demo

showcase

This is a 2d grid-based space game built with avian2d. Each cell in the grid has properties such as "gravity". The levels are serialized and loaded via JSON.

minecraft settlement generation

Settlement Generation Challenge in Minecraft

showcase

SpecificProtagonist won the AI Settlement Generation Challenge in Minecraft (presented at the IEEE Conference on Games) with a project that uses bevy_ecs .

This was part of Generative Design in Minecraft (GDMC) and the source code can be found on GitHub

bevy_typst

bevy_typst

showcase

typst is a replacement for LaTeX written in Rust, and vello is a 2D graphics rendering engine written in Rust, with a focus on use GPU compute shaders. Vello has a bevy integration in bevy_vello.

bevy_typst integrates typst and bevy using vello as a rendering engine to render typst documents inside of Bevy.

destructible planetplanet

Destructible planetary tech

showcase

WIP destructible planetary tech. The mesh, texture and destruction are all procedural. The earth is using real elevation map and ocean depth map to create an exaggerated relief bump. The lava is using simplex noise and animated with globals.time offset, which is Res<Time> that is available in shaders.

to build a home

To Build a Home: duties tab

showcase

The "To Build a Home" duties tab detects if your character has gone to work and paid rent in time. The consequences of failing are shown, but can't be enforced yet.

The game has additionally started using mlua, which gets a sandboxing discussion in the Discord thread.

bevy_replicon

Top-Down Game

showcase

This shows the initial work on a top-down multiplayer game, which is powered by bevy_replicon.

satisfyingsatisfying

Unexpectedly Satisfying

showcase

A small ship shoots around the screen leaving permanent effects on the playing field while colors change over time.

notifications stack

Notification Stack

showcase

A notifications stack using vanilla Bevy UI types implemented in Jarl

roadsroads

Project Harmonia: Roads

showcase

Project Harmonia implemented initial road support. Currently segments are used for road creation, with Bezier curve support is planned to allow for curved walls and roads.

2d platformer2d platformer jump

2d platformer

showcase

A wip 2d platformer using bevy tnua, dolly, bevy_ecs_ldtk and avian2d

gem designrendered gem

Gemstone Ray Tracer

showcase

A realtime gemstone ray tracer with attached modeling program for creating gems.

circular scope

Quartz: Circular Scope

showcase

A circular scope visualization introduced to quartz. This scene is assets/circular-scope in the quartz visual programming/dsp repo.

gizmo truck hud

Space Truck HUD

showcase

A gizmo-driven heads-up display on a space truck.

This is taken from a WIP open-world space game where players master orbital dynamics to fly challenging missions like smuggling contraband past patrol satellites, deploying telescopes at Lagrange points, or making deliveries between binary planets. Like KSP, but focusing more on flying & operating spacecraft, with detailed interiors, life support, and n-body gravity.

There's some interesting benchmarking of gizmos vs other approaches in the discord thread as well.

sandfall

Compute Shader Sand Simulation

showcase

A compute shader sandfall simulation upgraded to bevy 0.14.1. It now uses atomic operations instead of swapping two buffers on the GPU side.

A bunch of historical videos along the progress of this project are included in the Discord thread as well as a suggestion to read SandFallIntro if you're going to attempt a similar thing.

quibble race

Quibble Race-inspired game

showcase

A spiritual successor to Quibble Race as a Jackbox style party game

goal oriented action planninggoal oriented action planning

Goal Oriented Action Planning

showcase

A work-in-progress crate: Set up some state fields, some actions, define when actions can be taken and the planner handles the rest.

falling sand inspired landscapefalling sand area selection

Falling Sand Bending Brawler

showcase

A falling-sand inspired prototype: a falling sand bending brawler! There are three moves currently:

  • Grab (Pick up a block of particles to throw a player)
  • Set (Return the held block back into the sand sim)
  • Parry (Reflect a held or thrown block of particles away from the player).
character animation

Character Animation

showcase

An animation graph implementation showing character bones and controls.

inverted attractor particles

Particles in Bevy

showcase

A simulator where particles spread out evenly over time, if left alone.

Crates

New releases to crates.io and substantial updates to existing projects

bevy_easy_config

crate_release

bevy_easy_config is a plugin that allows you to load config files and instantiate them as a resource.

Usage

First define the struct that you would like to load, and impl/derive the relevant traits:

// Define the struct to load
#[derive(Deserialize, Asset, Resource, Clone, TypePath)]
struct Settings {
    some_keybind: KeyCode
}

// Default also needs to be implemented
impl Default for Settings {
    fn default() -> Self {
        Self {
            some_keybind: KeyCode::KeyW
        }
    }
}

The add it to your app:

use bevy_easy_config::EasyConfigPlugin;

fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            EasyConfigPlugin::<Settings>::new("settings.ron"),
        ))
        .run();
}

This will load the file located at assets/settings.ron, into the Settings struct and insert Settings as a resource.

fn some_random_function(
    settings: Res<Settings>
) {
    // ... Your awesome code here
}
bit_gossip

bit_gossip

crate_release

bit_gossip is a pathfinding library for precomputing all shortest paths in a map, so that you can retrieve a path from any node to another in constant time.

card games

bevy_la_mesa

crate_release

A crate to build card-games (Hearthstone, etc) with bevy

woodpecker ui

WoodpeckerUI alpha

crate_release

Woodpecker UI is a Bevy ECS driven user interface crate. Its designed to be easy to use and work seamlessly with the bevy game engine. This release is the open sourcing of the crate and a crates.io release will come in late August.

Check out the examples in the preview YouTube video

Features

  • Bevy ECS first UI
  • Easy to use widget systems
  • Flexable UI rendering using vello
  • Taffy layouting
  • Cosmic Text for text layouts
  • A few helper widgets to get you started
text anchor

bevy_ui_anchor

crate_release

Anchor UI nodes to either fixed points in the world, or another entity.

bevy_ecs_tiled

bevy_ecs_tiled v0.3.4

crate_release

Work with 2D tilemaps created using the Tiled map editor. Built on top of bevy_ecs_tilemap. 0.3.4 adds new examples for Rapier and an isometric map, properly handles z-order, and the ability to map Tiled user properties to Bevy components.

bevy_light_2d

bevy_light_2d v0.3.0

crate_release

bevy_light_2d is a general purpose 2d lighting plugin. 0.3 now includes light occlusion and dynamic shadows.

Devlogs

vlog style updates from long-term projects

Construindo um jogo usando RUST e BEVY

devlog

This is the developer's first dev log ever. The video is in Brazilian Portuguese and an english version will also be released.

Educational

Tutorials, deep dives, and other information on developing Bevy applications, games, and plugins

Designing Cyclic Puzzles for Simon Says

educational

This post covers the cool mathematics behind cyclic puzzles that were involved in working on Simon Says, a Bevy Jam 5 entry.

Extreme Bevy

educational

Extreme Bevy is a tutorial series about how to make a low-latency p2p web (and native!) game to the latest versions of Bevy, Matchbox and Ggrs. This tutorial series inspired the creation of bevy_xpbd (now Avian Physics).

Pull Requests Merged This Week
Contributing

Want to contribute to Bevy?

Here you can find two types of potential contribution: Pull Requests that might need review and Issues that might need to be worked on.

How do I contribute?

Pull Requests Opened this week

Issues Opened this week