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
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.
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
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 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: 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.
Top-Down Game
showcase
This shows the initial work on a top-down multiplayer game, which is powered by bevy_replicon.
Particles in Bevy
showcase
A simulator where particles spread out evenly over time, if left alone.
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.
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-inspired game
showcase
A spiritual successor to Quibble Race as a Jackbox style party game
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).
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.
Crates
New releases to crates.io and substantial updates to existing projects
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_ui_anchor
crate_release
Anchor UI nodes to either fixed points in the world, or another entity.
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
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.
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.
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
}
Devlogs
vlog style updates from long-term projects
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).
Explicitly order `CameraUpdateSystem` before `UiSystem::Prepare` authored by benfrankel
Fix num_cascades in split_screen exmample for WebGL authored by akimakinai
Add link to `with_children` in `with_child` doc authored by rparrett
update `hashbrown` to `0.14.2` authored by soqb
Make `QueryState::transmute`&co validate the world of the `&Components` used authored by SkiFire13
Expose winit's `MonitorHandle` authored by tychedelia
Glam 0.28 update - adopted authored by RobWalt
Improve documentation on Update vs FixedUpdate schedule dichotomy authored by ItsDoot
Export glTF skins as a Gltf struct authored by barsoosayque
Add `Reflect` to `OnReplace` authored by Lubba-64
Separate component and resource access authored by cBournhonesque
Add `invert_winding` for triangle list meshes authored by DasLixou
Fix gizmos regression authored by Lubba-64
Making `bevy_render` an optional dependency for `bevy_gizmos` authored by Neo-Zhixing
bevy_reflect: Function registry authored by MrGVSV
bevy_reflect: Update serde tests for `Set` authored by MrGVSV
Fixed typo authored by cactusdualcore
Fix access conflicts for resources authored by cBournhonesque
Fix soudness issue with Conflicts involving `read_all` and `write_all` authored by cBournhonesque
Add a ComponentIndex and update QueryState creation/update to use it authored by cBournhonesque
Add 2d opaque phase with depth buffer authored by IceSentry
bevy_reflect: Anonymous function parsing authored by MrGVSV
bevy_reflect: Add `DynamicSet` to `dynamic_types` example authored by MrGVSV
bevy_reflect: Update internal docs regarding anonymous function type names authored by MrGVSV
bevy_state: Make `reflect` module public authored by MrGVSV
Adding Reflect data types for `States` and `FreelyMutableState`. authored by eckz
Fix TAA on camera with viewport authored by tychedelia
Mod picking upstream 2 authored by TotalKrill
inline iter_combinations authored by re0312
A Curve trait for general interoperation — Part I authored by mweatherley
Explicit using clone_from authored by re0312
Fix 3D Gizmo webgpu rendering authored by AFKessen
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.
Pull Requests Opened this week
Fix query transmute from table to archetype iteration unsoundness authored by SkiFire13
Animation player scene root authored by spooky-th-ghost
Fix query transmute from table to archetype iteration unsoundness (alternative) authored by SkiFire13
Meshlet software raster + start of cleanup authored by JMS55
feat: add `insert_if_new` (#14397) authored by jpetkau
Animated gizmos authored by RobWalt
bevy_reflect: Function reflection benchmarks authored by MrGVSV
document using `ObserverState` as filter for `Observer` `Entity`s authored by databasedav
Queries as Entities authored by Trashtalk217
Add trigger_map to support triggering mapped events authored by cart
Adds storage buffer asset authored by tychedelia
Identify a subset of texture formats suitable for rendering in preparation for #13146 authored by Brezak
New utility methods on `InfinitePlane3d` authored by RobWalt
Improve the gizmo for `Plane3d`, reusing grid authored by RobWalt
Switch rotation & translation in grid gizmos authored by RobWalt
Fix broken bezier curve benchmark authored by mweatherley
Use `Isometry` in `bevy_gizmos` wherever we can authored by RobWalt
Observers overhaul: statically-typed multi-event-listening and safer dynamic-event-listening authored by ItsDoot
Opportunistically use dense iter for archetypal iteration in Par_iter authored by re0312
Implement `Resource` for `()` authored by Lubba-64
A Curve trait for general interoperation — Part II authored by mweatherley
hooking up observers and clicking for ui node authored by TotalKrill
Use `map_unchanged` in reflection instead of creating a `Mut` manually. authored by chescock
Remove redundant `ArchetypeComponentId` lookup in `Res` and `ResMut` authored by chescock
Add query reborrowing authored by SkiFire13
Make bevy_math's `libm` feature use `libm` for all `f32`methods with unspecified precision authored by mweatherley
Issues Opened this week
SceneInstanceReady trigger context authored by ChristopherBiscardi
Support reflection-based serialization on bundled hash set implementations authored by kleinesfilmroellchen
`Commands` apply at unexpected times with exclusive `World` access authored by jrobsonchase
`Query::transmute_filtered` doesn't respect the new filters authored by SkiFire13
Docs for bevy_reflect::impl_reflect imply that they can be used by user code to implement Reflect for foreign types authored by ariofrio
Implement `Resource` for `()` authored by alice-i-cecile
Add Stochastic Screen-Space Reflections authored by Bcompartment
Example for saving assets authored by viridia
Shadows disabled when second camera is activated authored by viridia
Buildable `ParamSet` authored by WinstonHartnett
`build-wasm-atomics` CI check failing authored by BD103
Meshlet simplification might be a bottleneck in bevy's Nanite solution authored by Scthe
Create a custom diagnostic for observer system params order authored by RomainMazB
More anti-aliasing options authored by Bcompartment
Grid gizmo seems hard to handle authored by RobWalt
`World::clear_entities` causes observer logic to break safety authored by Jacob-JB
Observers that can observe multiple different event types authored by ItsDoot
Document all_tuples_with_size, and its difference to all_tuples authored by ItsDoot
Time-keeping broken with `UpdateMode::Reactive` (X11 and WASM) authored by Azorlogh
Improve update_mesh_previous_global_transforms() performance authored by JMS55
`msaa_writeback` is inefficient authored by Elabajaba
Improve CompressedImageSaver authored by JMS55
Gizmos circle_2d does not appear for the first few times it is requested after bevy startup authored by recatek
Collecting into a vec leads to better performance for `iter_combinations_mut` authored by alice-i-cecile
Hot asset reloading example does not update when saving torus.gltf authored by Anti-Alias
Consider using `fake_variadic` to improve docs authored by janhohenheim
Gizmos broke on WASM authored by simbleau
Watching entity after spawning an observer can contribute to unnecessary bugs authored by kaphula
Custom Asset IO example not loading assets on website authored by akimakinai
differences in colour between gpus authored by bananaturtlesandwich