Hi everyone, this is Winnie, Team Stonehearth’s intern! I’ve been working on biome and terrain generation for the past two months, and I’m really excited to share some features with you that you might eventually see in game!
To summarize the work I’ve been doing: World generation can now be controlled and modded through a large set of control parameters. Most of these parameters were hidden in the lua code before, but they are now exposed in one consolidated and moddable file!
And now, here are some cool things we can do by editing the file:
Making New Biomes
Changing the size of mountains:
Adding new flora (trees and plants), setting the distribution of flora for each terrain elevation:
Changing the size of lakes:
There are quite a few other parameters you can play around with, and these are just some that I personally had a lot of fun with.
Subheader: Introducing Simplex Noise
We had to redesign the code for generating terrain and placing flora, because flexibility and precision were difficult to achieve with some of the parameters of the original methods. I’ll just talk about one major change in depth, as it’s pretty interesting and is fairly representative of other changes that we made!
One thing you might have noticed in the current world maps is that large lakes and large mountains are rather scarce. In fact, generating large lakes and mountains that looked good actually couldn’t be done with the old generation code.
There used to be three major steps in generating the terrain:
- We used shaped noise to determine the terrain type (plains, foothills, or mountains) for each 8 by 8 square on the overview map, which we call a ‘tile’.
- We again use shaped noise to generate detail within the tile, with the average elevation of the tile determined by the assigned terrain type.
- We smooth out the boundaries between tiles so it looks continuous.
Here is a visual example, with a highlighted mountains tile for reference:
As you can see from this overview map generated using the old method, the problem is that it is difficult to get interesting large scale structure in the world. (In more technical terms, the noise generator is missing the low frequency components that allow for larger structures.) The tile based noise-generator tried to give a more 8-bit Zelda like feel to the map by providing some blockiness at the world-level but the technique was only marginally successful and started to show its limits at larger scales.
Our solution was to replace the two-level noise generator with one that would work at all scales, both large and small. Fortunately, there exists a noise generator with exactly these characteristics, and it’s called ‘simplex noise’. Simplex noise works well because most natural things in the real world have big variations at big scales and small variations at small scales. So, if you take random noise and shape it such that the variations (amplitude) of the noise decrease at smaller scales (higher frequencies) you can imitate things like terrain, clouds, textures, and many many other things, and this is exactly what simplex noise is designed to do!
Here, you can see the terrain looks with the new noise generator:
I won’t go into more detail about how simplex noise works, but it’s widely used in graphics to generate spatial randomness and is really elegant! If anyone is interested at all, this website explains it fairly well. Ken Perlin, the person who came up with the idea, actually won an Academy Award/Oscar for it because it became so useful in the movie industry for CGI effects.
So the new terrain generation process is:
- Each square on the overview map gets assigned a random value using Simplex Noise,
- The values are then converted to different layers within the three terrain types, based on other parameters such as amount of mountains, maximum height of mountains, etc.
The shaped noise for the water placement also suffered from the same problems, so we also replaced that noise generator with simplex noise and were able to get a more varied range of water body sizes. Other methods such as placing plants, boulders, and terrain edge-crumbling also utilize simplex noise in some way!
And finally, here are a few examples of what you’d be able to do with these terrain/biome parameters:
Other Brief Updates
Thanks to Winnie and Albert for this awesome Desktop Tuesday! Winnie is just now wrapping up her summer internship, but we have been incredibly pleased to have her work in Stonehearth. Her code will (probably) enter the main release branch in Alpha 12, but please do not expect to see it in-game until we figure out exactly how to manipulate those json files to produce optimal visual and gameplay results.
In the meantime, Tom, Chris, Brad and I (along with several Rising Thunder team members) are still in Seattle, after four densely packed days of showing Stonehearth and RT in the Indie Megabooth at PAX Prime. This means a few things:
ONE: No stream today (Tuesday, 9/1), as we have all been talking nonstop all weekend (endless booth duty for four straight days , woo!). Streams return as usual on Wednesday, 9/2.
TWO: Many thanks to all of you Kickstarter and Steam backers who came to the booth to show your support, and tell us how far we’ve come since you first found us. Thank YOU for bearing up under all the bugs and for your patience with our approach to new features
THREE: to the young gentleman who made THIS MUSHROOM on the demo machine, it was a pleasure hanging out, and we hope to see you in our community soon. Your “Mushroom Lord” title awaits you. 😉
FOUR: Extra special (most humble! personal! everything!!!) thanks to Mike Laidlaw, for that inspirational ten minute conversation on Friday. Other than Stonehearth, I play only one video game these days, and it is yours. It was the highlight of my weekend (and maybe my entire professional career thus far) to hear that after a hard day working on your own video game, you come home and play ours.