2D Tilemap using UV Coordinates with nice transition between different tiles?
I am making a top down 2D game that has procedural terrain, and am trying to make the transition between tiles look nice.
I had this working by generating an object for every tile. I would then add a child sprite for the base tile type. I would then add another set of child sprites depending on the neighbors. If a dirt tile was next to a grass tile, the dirt tile would have the base dirt sprite, and a transitional grass sprite that was basically halfway transparent. This system was really nice because I just had a to create a 6x4 texture atlas per terrain type. (https://github.com/seveibar/liberated-pixel-cup/blob/master/resources/assets/lpc_full_assets/base_assets/water.png)
However I recently switched to using a single mesh, and altering the UV coordinates to show the generated terrain. This reallllly improved my performance, but seemingly harmed my flexibility.
I've been searching for a way to "map multiple sprites at a single location on a mesh" but haven't found anything concrete. I've attempted using uv2, uv3 but that doesn't seem to work either (came up all yellow, no sprites).
I don't want to create some giant spritesheet that has every possible permutation of tile types being next to eachother.
The other idea i had was to create multiple stacked meshes, and paint the transitions on a mesh above the base terrain mesh. That's going to really increase the vertices i am looping through though :/
Is there a standard way to handle this?
Answer by Seedersj · Apr 21, 2016 at 04:14 AM
Well I figured out i can use mesh.uv2 if i set the Secondary Maps -> Detail Albedo x2 texture to the same atlas, and then set UV Set dropdown to UV1.
UV1 = mesh.uv2
However, that's still only 1 extra texture. Maybe I need to learn to write a custom shader for this?