#06 Terrain Texturing


So I've spent days tinkering with shaders and tiles, renderers and custom scripts trying to achieve the style I've been striving for. And after many attempts and varying approaches, I've finally found at least the beginning of a solution.

The idea was to create a sort of UV tile texture, right now exclusively looking at grass, and using a colour map to lookup biome colours and keying out sections of the tile texture to create a gradient between the biomes. At first I tried achieving this with a shader, but that proved to be a fruitless nightmare, since it would overwrite the previous tiles with the last tile processed. Then I moved on to creating my own TileBase derived script, inheriting the basic behaviours of Unity's tiles while implementing my own methods, and after a lot of experimentation, I got it working. Although it's not completely finished, as I want the gradient to be more natural, that is simply processing and assigning colours to the appropriate slots in an array, which is little more than grunt work at this point, I thought I'd show off the progress.


It doesn't look too dissimilar to the previous version with the tile tint, because I used the tinting process in the generation of the tiles. By looking up the tile's main colour by using the perlin values of temperature and precipitation as coordinates on the colour map, I then was able to assess the neighbouring tiles' colours and mix the colour assignments on a tile by tile basis. This leads to a fairly smooth pixel gradient, almost like dithering. There is a border of uncoloured tiles on the edge because although they will have the colour tint value assigned to them, they don't have all the neighbours necessary to evaluate an accurate colour assignment that will blend between chunks. In the main world generation, I will have to load invisible chunks around the edge of the render to account for this.

Right now the code is very inefficient, and quite computationally taxing, but I have some ideas of how to trim that down and once the proper colour assignment is done, I'll get to work on making it playable. But right now, I need to focus on the proper assignment values and lerping between the tint values to make proper gradients along both axes. This is such a massive step forward in the stylistic terrain I've been trying to achieve, but there is still a ways to go.

Next on my ever-growing to-do list will be features, like snow, trees, flowers, and proper grass. Though I've been having a few doubts about the actual artistic direction of this project. My strongest pixel art style tends to be side on, which is somewhat forgivable in a top down environment but the more work I make, the more it feels out of place with the terrain I've spent so long working on, so I'm debating whether I should lean more in a Don't Starve direction of having a sort of tilted camera, more of an orthographic approach, with billboard sprites and a little more of a 3D environment. At this point though it doesn't really matter, I'll keep working in a way I'm comfortable with and eventually it will all gel together.

- - - UPDATE - - -

And just like that, I've done it. By using a custom gradient tile class to assess and replace pixels with colours determined by neighbouring tile tint values, I've finally got a working method of rendering terrain to a standard I'm happy with! You can check the code on the GitHub repo HERE, but here's a few examples of 32x32 chunks generated using this method.

So just like that I have a whole system for terrain generation. Although it's been developed in an experimental scene isolated from the core scripts, it should be relatively simple to implement and streamline. Hopefully the asynchronous methods for world generation already in place can offset some of the processor lag from this method of rendering, but even if not, there are plenty of ways to go about trimming down some of the fat. This was tough to pull off and honestly was getting me down for a bit, but I've finally made it and I'm full of energy for the next task(s)!

- - -

In between working on the terrain, I've been throwing together some more animals to populate the world, so I'll leave you with some of those.


Eventually I'll need to actually implement some animal AI, but in the meantime it's kind of nice to just draw them and imagine what they'll be like in the game. I'm signing myself up for a hell of a time animating though!


Anyway, that's it for now. Until the next time, take care.

Ryan.

Leave a comment

Log in with itch.io to leave a comment.