This isn’t really a specific technical question, but more of a broad question with how I’m looking to solve a problem. What I’m doing is I’m generating a terrain mesh for a top-down style game, with the terrain split into a series of different biome/terrain types. The world generation can generate can expand as far as the player travels, so the terrain itself it split into 32x32 tile chunks that are generated or loaded as the player approaches. The terrain doesn’t use unity’s built in terrain system at all, it’s just a generated mesh.
Basically, one of the big issues I’m having is how to transition between the different terrain zones. Each zone has a few different textures, and when it comes to the boundaries, I have to find some way to make the zones transition smoothly into each other.
Currently, the terrain looks something like this (sorry, no trees or foliage yet!):
Originally my plan was to break up the mesh and apply different blended textures as needed, but that turned out to be unreasonable, especially when multiple zones boundaries meet at once. So one thing I’m considering is rendering the texture by basically alpha blending the terrain texture layers on a separate camera, rendering that to texture, and then copy it to a texture2d and apply it to the terrain.
What I’m not sure is if this method is the best solution, or even if it’s really feasible. It won’t be real-time, it only needs to be done once per chunk when it’s first loaded (which, at most will occur 3 at a time depending on the players movements). Anyone have any ideas on this approach, or a better approach to follow?
Anyone with any thoughts on this? Basically I’m just wondering what would be the best way to generate textures for a terrain that’s generated on the fly that contains potentially many different textures. The details aren’t really that important on how to do it, but more of what would be the best technique to approach the issue with.
Can you control the maximum amount of touching biomes?
If so, perhaps a simple shader solution would suffice, use vertex colors as blend weights (same way as the unity terrain works) and a shader to blend between different textures - you can assign base textures to the material for that biome’s mesh as it’s generated. With vertex colors you can easily blend 4 different textures (R/G/B/A), more if you’re willing to do some encoding/decoding with the vertex color.
Not saying it wouldn’t be possible to use render textures how you described, it just sounds kinda painful not to mention having a unique non-tiling texture cover your entire terrain would be a massive memory hog.
Should be no need for projectors, if you’re generating the mesh you can just as easily generate UV coordinates that are projected from a plane which would give you the exact same result without the re-draw overhead.
Another option (depending on how clean your geometry is) is to generate triangle strips along the borders that are flush with the terrain and use a transparent shader with an offset property to avoid z-fighting.
Looking at how Warcraft 3 deals with terrain transitions might also give you some alternative ideas.
They use a regular terrain grid and each terrain type has a layer, when there is a transition in a terrain quad it overlays a tiling edge texture - grass always above dirt, long grass always above short grass ect. You might be able to minimise the amount of biome intersections if you deal with them like this.