Razarion is an open-source multiplayer RTS that runs in the browser. All players share one
persistent planet — no matches, no lobbies, no download, no registration. It is in alpha, so
expect rough edges.
Babylon.js does all the rendering. The game engine is Java compiled to WebAssembly with TeaVM
(WASM-GC), so client and server run the identical simulation code; Angular drives the 2D UI.
A few Babylon.js details:
Terrain tiles blend land, beach and underwater in a singleNodeMaterial, by vertex
height with smoothstep — no seam at the shoreline. The grass/sand splatter mask is
procedural (domain-warped Perlin, 512×512) and its normal comes from screen-space derivatives
of the mask, so no extra normal texture is needed.
Water is a NodeMaterial with a per-tile reflection CubeTexture, plus a whitecap
material assembled programmatically from node blocks, ribbon wakes and a bow-wave halo per
ship.
Units are glTF through AssetContainer and AnimationGroups; explosions, beams and muzzle
flashes are node materials too — roughly 120 across the codebase.
The in-game content editor opens the Node Material Editor and the Inspector on the live
scene, so a material can be tuned in the running game and saved back to the server. Easily the
biggest productivity win of the whole project.
Update: the beginners’ island got a new ground. Here is a devlog of the work, with before/after comparisons for each step:
The island used to look flat and boring, so this is what changed:
Hills and relief: gentle hills on the land. A web worker computes sky visibility and curvature for each terrain tile, including across tile edges. The ground shader uses them to darken hollows, lighten crests and keep the sky light out of places the land hides.
Ground materials follow the shape of the land: lush grass in hollows, dry grass on crests, bare earth on slopes, stony ground at the foot of rock. Each material mixes large and small noise, which replaced the random splatter mask (and freed a texture unit). The texture coordinates are warped by large-scale noise, so the 16 m repeat no longer shows as a grid.
Generated textures: the grass and earth textures are now generated instead of photographed. The alpha channel carries height, so grass grows into earth one tuft at a time. The photo grass put its contrast into single blades and looked like carpet at RTS camera distance.
Light: low side sun, ACES tone mapping and contrast/saturation as a post process, plus image-based lighting for units, buildings and plants. (The IBL had never loaded, because the .env decoder shader was missing from the bundle.)
Life: drifting cloud shadows (simplex noise in the shader), plants that sway in the wind (a material plugin), and trodden paths from the start pads to the coast.
Sprites stand on the ground: vegetation sprites use the same ground rules on the CPU as the shader does on the GPU. They get darker growth at their foot and are shaded by the same sun, sky and cloud shadows.
Two other changes since my first post:
The code is now under the MIT license (it was LGPL).
The game starts noticeably faster, especially on phones: less data per start, and the game no longer waits for the models to arrive.
I’d love feedback on the ground. Does it read as natural terrain at RTS zoom, or does something still look tiled? If you know a cheaper way to do the per-tile relief (sky visibility and curvature) than computing it in a worker, I’d like to hear about that too.