Updates Metal Renegades: Terrain Generation Improvements

Lorxu

New Member
Project progress board: https://trello.com/b/HKc9QHQl/metal-renegades-gsoc-2021
Project proposal:
Overview:
This project concerns implementing a new terrain generator for Metal Renegades. Currently, the world of Metal Renegades is an endless desert, but I'll add more interesting terrain typical of the Old West: mesas where rock around a plateau has eroded away, canyons where rivers have cut deep into the rock, mountains made of rock instead of sand, and more. I'll also try to create a realistic distribution of flora and fauna, and include as much realism as I can while still remaining performant and fun to play.
 

Lorxu

New Member
Progress Update:

This week, I worked on adding rivers to Metal Renegades, and updating the Tutorial World Generator, which was previously broken and outdated. The tutorial works now, and rivers look pretty good. I implemented rivers specifically for Metal Renegades instead of reusing the rivers from CoreWorlds because at high elevations like in mountains, those rivers would just carve 16 blocks or so into the ground, not get to sea level, and not generate any water. Instead, the new rivers carve all the way down to sea level, with varying steepness so that sometimes it generates canyons, and sometimes gentle slopes:



Meeting overview:
  • I gave an overview of my progress as described above.
  • We had a lot of discussion on improving the performance of world generation, especially optimizing the order in which chunks are generated, but didn't really come to any conclusions. I plan to look into it more this week, and hopefully do some profiling as well.
  • We discussed some issues arising from the river implementation, specifically that wells, houses, and the player could spawn underwater, and decided to add them to a new section of the Trello board.
  • Next week, I'll be focusing on biomes, adding four new biomes with associated surface block and plant generation. They'll be mostly placed according to terrain features, for example a rocky biome on mountainsides, and a wetter biome along rivers.
 

Lorxu

New Member
Progress update:

This week, I worked on two different things:
  • First, I reworked some of the chunk processing code so that chunks always generate in order of distance to the player. This change is still in progress, so players won't see any improvement on the main branch of the engine quite yet.
  • Second, I added new biomes to Metal Renegades. There are four new biomes, but only three actually generate: a rocky biome for mountains, which are now made of stone instead of sand; a riparian biome with lots of plants for near rivers; a scrubland biome which replaces some of the flat desert, with dry dirt and a few plants; and a steppe biome, which will eventually be a forested biome that generates on flat areas at high altitudes, but currently doesn't actually generate anywhere since there aren't any flat areas in mountains yet. It will be added in when I add mesas.
Meeting overview:
  • We discussed the change to the chunk processing order, including some design discussion and clarification of the way some things currently work. I plan to test it some more next week, including trying out chunk level-of-detail to make sure it hasn't been affected.
  • I explained the way I implemented the new biomes: there's a base biome provider which just generates desert and scrubland, then the providers that change the elevation to make rivers and mountains also change the biome in those areas to match.
  • We looked at the open pull requests relating to the biomes, including one which fixes a mistake I made where I used a relative position instead of a world position. We talked about how to avoid similar bugs in the future: making wrapper classes for types of positions would work, but isn't worth it at this point due to performance issues with too many wrappers and also the amount of code that would need to be changed; I'll make a unit test for this particular case, but that won't really help avoid future bugs, so we didn't really find a good solution to that problem.
  • I'll be out of town for a lot of next week, so I won't be able to get as much done, but I'll use the time I have to start working on adding terrain features like mesas and strata.
 

Lorxu

New Member
Progress update:

I didn't have that much time this week, but I continued work on the things from last week. I participated in some discussion and review of changes to improve world generation performance, and polished biomes. Here's a screenshot with all four currently generating biomes (desert, river, mountain, and a very small patch of scrubland), which also shows the noisy blending that now occurs on biome borders:



Meeting overview:
  • We discussed concurrency mechanisms: the codebase currently uses several ad-hoc concurrency mechanisms, but it makes sense to try to unify at least some of them. There's a currently open PR which uses the RxJava library for concurrency, which may be the way it's done in the future. My PR on chunk ordering will probably wait until that is merged or another standard concurrency method is decided upon, because it currently manually creates and manages threads.
  • I mentioned the main biome-related issues that remain, which is that rivers and river biomes are too frequent and too wide.
  • Next week, I'll finish up a PR fixing a problem in the engine which is needed for my biome implementation, and fix the tests in the chunk ordering PR. I'll also start working on rock strata and mesas, which will probably involve some new block types from another module.
 

Lorxu

New Member
Progress update:

I forgot to post here last week, so there's two weeks worth of updates here:
  • Rivers were reworked a bit more to fix some problems. They should now be a consistent fairly narrow size, and nothing should spawn underwater.
  • Rock strata were added to mountains:
  • I started working on mesas, but they're still a work in progress.
  • I fixed a bug where the advanced world setup screen, including a preview map of the world, would crash. This was a side effect of the changes I made earlier to the biome system.
Meeting overview:
  • We discussed what I worked on in the past week, as seen above.
  • We talked about plans for the future:
    • I'm going to add trees to steppes, and will probably want to add a new tree type for something like a juniper pine. That will use the GrowingFlora module, so I'll need to learn about L-systems and potentially update the module as well.
    • Scrublands should eventually have some sort of dry-looking grass instead of dirt. That could be accomplished with a new block, but there's also a block tinting feature which Terasology used to support which it might be worth it to bring back.
    • This week, though, I'm focusing on finishing mesas. I'm also redoing my chunk ordering changes with the new system we're planning on using for concurrency, the Project Reactor library.
 

Lorxu

New Member
Progress update:
  • I continued working on mesas. They now usually look pretty good, the main remaining thing is figuring out how they should interact with mountain ranges.
  • I rewrote my chunk ordering PR to use Reactor for concurrency.
  • I fixed a bug where rivers would sometimes generate upside-down, so that it looks like a little grassy hill instead of being filled with water.
  • I added some colors for the new biomes to the world preview screen, so that it's a better preview of what the world will actually look like.
  • I fixed the minimap in Metal Renegades, which was previously showing the wrong colors and weird grid artifacts but now looks right:
2708


Meeting overview:
  • I went over my progress above.
  • We talked about a bug where sometimes an area of the world will never generate unless you go far enough away that it unloads and then come back. We're still not sure what's causing it.
  • We talked about some other problems which are easier to fix, like that mesas are too rare and that sometimes the messy transition zones between biomes are way too big.
  • The plan for next week:
    • Fix the two small problems in the point above, and merge mesas into Metal Renegades. I'll work on the integration with mountains separately.
    • Fix the outstanding problems with the rewritten chunk ordering PR.
    • Try to figure out what's going on with the chunks that never generate.
    • If I have time after those, I'll start working on trees for steppes.
 

Lorxu

New Member
Progress update:
  • A couple finishing touches on mesas, and they were merged into Metal Renegades this week, so they're officially there. I'd still ideally like to work on the interaction with mountains, but I'm waiting until later for that.
  • I almost fixed all the problems with the rewritten chunk ordering PR - I'm still having concurrency bugs causing the tests to fail sometimes in Jenkins, but otherwise it works.
    • That includes figuring out the problem with stuck chunks and fixing it.
  • I brought back block tinting: the game used to change colors of grass and foliage based on the biome, but it was removed when biomes were extracted into a separate module, so I added it back with a new API. This is still in-progress, there's an open PR, but it does work at this point.
2709


Meeting overview:
  • We discussed the above progress, including some design questions regarding the API changes in block tinting.
  • We had a long discussion about how to make the order of facet providers that update existing facets deterministic and controllable. For example, the river provider should modify elevation to carve out riverbeds after the mountain provider has modified it to raise up mountains. We settled on adding a priority value in the Updates annotation, similar to a mechanism used by event handlers, so that any provider can control its order relative to other providers which update the same facet, so I'll work on adding that next week.
  • Other plans for next week:
    • I'm going to fix the tests of the rewritten chunk ordering PR for the last time.
    • There are a few improvements to the block tinting PR to make it more reliable, and I'll be testing it thoroughly as well.
    • I'll make use of the block tinting in Metal Renegades by making scrubland have a dry-looking grass surface instead of dirt. I'll also switch it to using the proper facet provider ordering mechanism once that's done.
 
Top