Gradients and normalization

A few things done this week. The most exciting and at the same time unexciting thing is that I'm not planning any more features for the playtest! Exciting because this means that there's a trajectory to release. Unexciting because I love adding features, and I do not love whatever the hell I have to do now, which is ... well, read on.

Gradient brush

My previous gradient brush was a bit buggy/dysfunctional, so it needed fixing. A few bits of work on this:

  • Gradient options are only enabled in GUI if a compatible type is selected; basically temperature, humidity or vegetation density.
  • Gradient brush falloff now works properly. This needs some extra storage, to store the max gradient delta per pixel. When you press-and-hold, you start painting deltas with a falloff, but as you move the cursor, the deltas get updated to the maximum value. These deltas are used with the "frozen" biome values (at the point of button press) to calculate the final values. Next time we start painting, these frozen values and the delta buffer get re-set.

Biome normalization

By allowing users to paint biomes, you can end up with tundras next to deserts. Ok, whatever floats your boat dear user! But in case the user desires some sensibility back into the map, now there's a button that does a normalization in terms of temperature/humidity, so that neighbour differences are smooth. It's basically a number of Gaussian blur passes.

Iconomorphic maps

This is something I wanted to do for a while. It was not necessary, nobody asked for it, except for my inner feature creeper voices. The original requirement was to just use a black and white image mask to specify continents shaped in a particular way. But why not take it a bit further and allow the colors to be mapped to biomes? It turns out that the whole thing 1) is not that hard to do 2) can be easily integrated with the current world generation pipeline. So here's what's going on:

  • The input image is cropped to square and resized to 512x512
  • Gather the representative biome colors in an array - it's 12 of them
  • Run K-means to reduce the number of colours to 12
  • Match the k-means colours to the palette colours, so that the total Euclidean distance is minimised
  • Now we have a target biome per pixel
  • Prepare a special image where each pixel stores the min/max values for each of temperature/humidity/elevation for its associated biome
  • The compute shaders that generate the world, when calculating elevation/temperature/humidity, they clamp the calculated values to the one provided by the image, if an image is provided
  • That's it - the biome is calculated naturally from the clamped values, rather than enforced, as this way we maintain some randomness within each biome's allowed range (because we clamp the values to a valid range, rather than enforce a biome with fixed values for temperature etc)
  • Extra bonus: by selecting a "silhouette" option in the world generator, the temperature/humidity ranges are ignored

Enter the Matrix & bug reports

Ok that's an interesting one. It so coincided that I read about EU pivoting away from Teams and to Matrix for sovereign communications, so I thought "cool". Then you have Discord start talking about requiring face recording, and given their recent data leaks, that's a bit stupid to say the least. At the same time, I've been thinking to form some mini community around the playtest and the game overall, because so far without anything playable, there's no point of course. So, where to form the community? So far the goal was Discord. But again, given the conjunction of the above, I thought I'd give Matrix a try. It turns out it's not as complicated as I read it would be (at least for my simple use-case), and there's Cinny that makes it very Discord-like too. So, the plan is to have a public space in Matrix, and if there can be automation, maybe there could be something on Discord too for a while.

And talking about automation. I need a way to provide people the opportunity to file some rudimentary bug reports from inside the game. Long story short, the easiest way that I thought of, and implemented, is to have a channel in Matrix which is purely for bug reports. There's a "bug report" screen now in the game, where if you submit the report, it uses a bot (with appropriate privileges) to post an entry into that channel. Of course, for data protection reasons, at the moment there's just bug title and details, and I think I can add some standard system/hw info safely, which will be invaluable.

Misc

  • Adding credits screen with some nice rolling text
  • Finally, as a bit of QoL, I've added tooltips for the different controls in World Forge.

That's all for this week, have a nice weekend all!