WebGPU + Wasm + Rust > building mmo-ready procedural trees using Ambient engine (part 1/3)

Emmanuel BOTROS YOUSSEF
4 min readJun 6, 2023

--

Within a week I built a fast and efficient low poly pseudo-random natural element generation system that could fit any mmo using Ambient, the next-gen cutting edge multiplayer engine. part 1 covers context and motivation, part 2 covers the generation system itself, part 3 is dedicated to randomness and how it can help us building up vast realistic ecosystems.

Hi there, I’m Emmanuel (mebyz) BOTROS YOUSSEF FEISTHAUER

see how the ramification system allows to naturally grow a well balanced tree

I’m a self-taught senior developer with a passion for creating innovative solutions in all kind of industries. In about a week i spinned up a simple pseudo-random procedural tree creation system/strategy for Ambient, the cutting edge game engine ( https://www.ambient.run ) powered by webgpu, wasm, and rust language.

TL;DR: visit https://github.com/mebyz and get in touch !

Over the years, I’ve gained extensive experience in digital media (streaming, news publishing mainly) and education ( learning management systems, and training ). Additionally, I have a range of diverse interests and hobbies that keep me busy. From tending to my tropical garden here in beautiful Reunion Island (France) to taking care of my beloved pets (a cat and a dog), i try to open my heart to all kind of new experiences. I also enjoy immersing myself in different genres of music, exploring new destinations worldwide, experimenting with cooking, and even brewing my own beers!

Since the early 2000s, I have been involved in the indie game development universe. Currently, my focus lies predominantly on rust language, wasm, and webgpu. One of my favorite hobby involves coding procedural generation algorithms for creating natural environments, encompassing vast terrains, trees, atmospheric effects, caustics, etc ..

Here’s why i wanted to share a bit of my last week building up a procedural tree creation system/strategies for Ambient, the cutting edge game engine ( https://www.ambient.run ) which targets webgpu, wasm, and rust language :

1/ WEBGPU

WebGPU shows the promising future of graphics and computing on the open web. One of the key advantages of WebGPU over WebGL is its low-level design that provides a much lower level of abstraction and more fine-grained control. WebGPU is also based on modern graphics APIs such as DirectX 12, developed by Microsoft, Vulkan, and Metal. WebGL, on the other hand, is based on the OpenGL ES 2.0 graphics API, which was primarily developed for mobile devices and embedded systems. Another advantage of WebGPU over WebGL is its cross-platform compatibility

2/RUST

The Rust programming language allows the developer to write faster, more reliable software. it helps you write faster, more reliable software. High-level ergonomics and low-level control are often at odds in programming language design; Rust challenges that conflict. Through balancing powerful technical capacity and a great developer experience, Rust gives you the option to control low-level details (such as memory usage) without all the hassle traditionally associated with such control.

Last but not least, Rust is strongly typed and statically typed. The types of all variables must be known at compilation time; assigning a value of a particular type to a differently typed variable causes a compilation error. Variables are declared with the keyword let , and type inference is used to determine their type.

3/ WASM (aka WebAssembly)

Firstly, it’s fast and efficient — WASM, aka WebAssembly executes at close to native speed by taking advantage of common hardware capabilities available on a wide range of platforms. Helpful if you’ve got the latest nVidia GPU.

Secondly, it’s safe — WebAssembly is a memory-safe, sandboxed execution environment that can be implemented inside existing JavaScript virtual machines

4/ Ambient game engine

Licensed under either of Apache 2.0 or MIT license at your option, Ambient is a runtime for building high-performance multiplayer games and 3D applications. it brings you the tools you need to build, run and scale multiplayer games, powered by Rust, WebAssembly & WebGPU.

some of the capabilities are :

  • Seamless networking: Ambient is both your server and client. All you need to do is to build your server and/or client-side logic: the runtime handles synchronization of data for you.
  • Isolation: Projects you build for Ambient are executed in isolation through the power of WebAssembly — so that if something crashes, it won’t take down your entire program. It also means that you can run untrusted code safely.
  • Data-oriented design: The core data model of Ambient is an entity component system which each WASM module can manipulate.
  • Language-agnostic: You will be able to build Ambient modules in any language that can compile to WebAssembly. At present, Rust is the only supported language, but we are working on expanding to other languages.
  • Single executable: Ambient is a single executable which can run on Windows, Mac and Linux. It can act as a server or as a client.
  • Interoperability: Ambient allows you to define custom components and “concepts” (collections of components). As long as your Ambient projects use the same components and concepts, they will be able to share data and interoperate, even if they have no awareness of each other.
  • Asset pipeline and streaming: Ambient has an asset pipeline that is capable of compiling multiple asset formats, including .glb and .fbx. The assets are always streamed over the network, so your clients will receive everything they need when they join.
  • Powerful renderer: The Ambient renderer is GPU-driven, with both culling and level-of-detail switching being handled entirely by the GPU. By default, it uses PBR. It also supports cascading shadow maps and instances everything that can be instanced.

5/ building naturals system (including trees shown in this article’s picture ^^) > will be shown in part 2 ;)

GO to part 2

--

--