Final Report - GSOC 2021
Terrain Generation Improvements for Metal Renegades
The goal of this project was to make the Metal Renegades game mode more immersive and interesting by adding new terrain generation that fits the Wild West theme of Metal Renegades. This includes biomes and plants as well as features like mesas, canyons, and rivers.
Some of the features added during the project
Outline
TutorialWorldGeneration
There’s a repository with a Terasology module and an online tutorial that goes over how to use Terasology’s world generation infrastructure. It’s pretty useful but unfortunately was fairly out of date, so I helped update it to work again, and added some information about some of the API changes I made as part of this project.
PRs:
Rivers
Terasology already has a simple implementation of rivers in the CoreWorlds module, part of the core world generator. But it’s not really sophisticated enough to use in Metal Renegades, so I wrote a new implementation of rivers. The most important difference is that if a CoreWorlds river generates in a mountain or other area with high elevation, it will carve out a riverbed that doesn’t reach sea level, and it won’t be filled with water; but in MR, rivers carve all the way down to sea level, in a way that’s engineered to generate decent canyons. Sometimes the rivers don’t quite reach sea level, and thus don’t have any water - this is a dry riverbed, and occurs in dry areas. Speaking of humidity, rivers in MR increase the humidity near them, and riverbanks are in a riparian biome with high humidity and plenty of plants.
A river
A dry canyon, created by the same mechanism
PRs:
Biomes
Instead of just an endless desert, I added four new biomes to make the landscape of Metal Renegades more interesting: a rocky biome for mountains, a scrubland biome with dry grass and some trees, a riparian biome for riverbanks, and a steppe biome for the tops of mesas. Over the course of the project I improved the biomes, adding features like trees to certain biomes, and I made some changes to the biome API so that it’s all implemented in a way that’s modular and maintainable.
A few of the biomes in Metal Renegades
API changes:
It used to be that a biome itself was just a biome ID, and other parts of the world generation pipeline had code to deal with specific biomes - for example, the primary rasterizer in CoreWorlds had a switch statement over the CoreWorlds biomes to determine which block to place. There’s still some of that, but I changed it so that some parts, like what blocks a biome is made of, are determined by the biome object itself, meaning that the new biomes from MR can be used in any gamemode and would still look mostly the same. (Plants still wouldn’t transfer, though.)
Block tinting:
Terasology used to have block tinting for grass, leaves, and other plants, where the color would change based on the biome; this was removed when the biome API was refactored a couple years ago, but I brought it back in a slightly different form so that, for example, scrublands can have dry-looking grass.
Trees:
I added two new kinds of trees, using the GrowingFlora module so that they’re varied and can grow over time. This required some changes to GrowingFlora as well, to remove some dependencies on things that Metal Renegades doesn’t want to depend on, and to fix some bugs.
A baobab tree in a scrubland biome
A juniper tree in a steppe biome
Other biome PRs:
Mesas
Mesas are a kind of mountain with very steep sides and a mostly flat top, which appear most often in dry areas. I implemented them in Metal Renegades, using a noise function with some fancy scaling. Another thing I had to implement to make them look nice is strata, the layers of different kinds of rock that you can see in the images below.
PRs:
Chunk generation ordering
When testing these features, I was often flying around generating lots of terrain. One thing that I sometimes found frustrating was that the chunks around me would take a very long time to generate, because the game was trying to generate chunks in other places. So, I changed the way chunks are generated to use the correct order, which updates whenever the player moves. This isn’t too much of a problem playing normally in single player, but playing on that PR (
Terasology#4822) made it a lot easier to test world generation.
Other stuff
I made a bunch of smaller changes, mostly fixing minor bugs in various different modules:
My experience
I had a lot of fun on this project! Procedural generation is really interesting and rewarding, and my mentors and the community were really supportive. This was my first time programming as part of a team, so I learned a lot about how to coordinate with other developers, review other people’s code, and other relevant skills.