I'm excited about #bevy 's upcoming new scene system! I didn't wait for it to be out, and made fernweh, a plugin based on the in-progress branch.

It's a tiny, but very handy plugin designed to help with chunk-based procedural generation. It lets you specify the procedural generation logic in a declarative way (what chunks should be visible at any point in time, what a given chunk should consist of) and takes care of asynchronously computing the contents of new chunks, and spawning/despawning chunks.

It's very, very generic, so it can be used in 2D and 3D.

Attached is the repository's example: you control the white disk, and chunks (materialized by colored polygons) spawn and despawn based on where you are.

Here the chunks are simple entities, but thanks to the new scene system you can have them be arbitrary hierarchies of entities.

Each chunk takes a little while to appear, because the example includes a `std::thread::sleep()` call to simulate computationally intensive calculations (think sampling random noise, collapsing wave functions...), but those are performed asynchronously, so they don't block interaction.

https://codeberg.org/glocq/fernweh/src/branch/next-gen-scenes

#proceduralGeneration

I added an example to my tiny #Bevy #ProceduralGeneration library, #fernweh , demonstrating how one may use it to implement "layered" chunk-based procedural generation, that is, procedural generation where some data is shared across several chunks. This is typically useful for large-scale terrain features.

The example below works in a similar way as in the previous toot: chunks are represented by colorful polygons, chunks close to the player (the white disk) get spawned, chunks far away get despawned, and there is an artificial delay to simulate expensive computations.

The difference is now chunks are grouped in groups of four chunks which share data (namely, a color — blue or red). The point is that data is only computed once, even though it is used by several chunks.

Fernweh is very flexible, so it is possible to use the same approach to group groups into even larger groups, or group chunks one way for one type of data, and another way for another type of data...

Keep in mind, though, that this relies on a yet unreleased Bevy feature, scenes (very likely to land in Bevy 0.19).

https://codeberg.org/glocq/fernweh/src/branch/next-gen-scenes

#rust