This post focuses on the work recently done on terrain generation. The kanban task title was:
Make it look like Toscana
Elevation
I played with Godot's FastNoiseLite generator. I used an asset configurator until I realized I could get the job done with a simple 2DTexture assigned to a TextureRect in a 2DNode. The editor's interface already makes all properties editable. Now I realize the FastNoiseLite devs have an online tool as well. Once I was happy with the elevations generations the noise would produce, I devised a way to generate a sea.
Sea
Everyone has a plan until they get punched in the face - Mike Tyson
Here was my plan to add a sea to any map:
- get the lowest point on the edge of the map, call it
$sea_source
- define
$sea_spread
as 0.9 or something, aka how far the sea will spread from$sea_source
- lower
$sea_source
elevation below 0 to$sea_depth
- starting on
$sea_source
as$source
, spread$source
depth to its 9 neighborsn
according ton.y -= $sea_spread*($source.y-n.y)
- don't spread from
n
ifn.y >= 0
after the sea has spread to it
This was a nice, simple idea, but I realized that when $sea_source
tuens out to be the lowest point of an area with
a high slope, it places the sea very close to a high mountain. Not ideal:
I had to find another idea...
What about vertically offsetting the overall elevation by $sea_spread ∈ [-1+sg, 1-sg]
,
where sg
is an arbitrary safe guard value that keeps the algorithm from generating underwater maps and maps with 0
water? Given that the noise generates a 2d matrix of values within [0, 1]
, it should make it rather easy to gauge how
much of the map will be covered with water.
It worked pretty well! Blue cells were looking rather dull though, so I set to find a water shader to pimp them up. godotshaders.com was very helpful and in no time I was set:
Ground Artefacts
Another thing that was looking very rough, were cells of type rock. I took a few props from Kenny's asset pack and randomly place them on the ground [1]. One detail though, is that the ground is not flat anymore, so placing thing on the ground isn't as straight-forward as it used to be; they had to be aligned on normals, otherwise they'd look like this:
I pulled my hair trying to understand how to unpack normals from Godot's Image, and gave up for now; computed them myself for now.
I had to align buildings as well.
I was looking for a grass shader too, but didn't find anything to start me up, and didn't want to spend too much time learning to make one from scratch. Maybe later :)
Overall, the game doesn't have a clear style yet, and we're actually pretty far from Toscana, but from a raw technical demo it's slowly turning into a bare-bones happy little prototype and I'm quite satisfied to be able to produce a design update like this one.
Don't focus on how much is left to go, focus instead on progressing in the right direction.
This update makes me happy to start the game. To my standards, it looks so much better now! I've also found what I think is a great inspiration for the art-style of citizen, so I can't wait to post the next update!
[1] if/when the project becomes more mature, I'll use unique assets, but props are good enough to build a prototype.