I have a procedurally generated mesh
(I use texture to uv map like 2d tile terrain)
Generated mesh:
But I want to make transition between different terrain types to look like that:
How could I do that? I am new to Unity and it is a problem for me.
I know I can have different tile transitions in my texture like below, but this solution does not suit me.
Maybe you can use one from pixel art scale algorithms, xBRZ for example.
I dont need to scale tiles, I need a method of creating translition beetween terrain types, blend between textures.
You could always use/write a shader that’s applies vertex color as a mask for your textures.
blue = water, green = grass, etc.
The transition will happen between two points of a different color; but the quality of that transition will highly depend on the resolution of your mesh, since it’s using vertex.
Could I somehow combine 2 tiles using mask like here in script?
Not using the method I described (unless you go crazy with the subdivision of the mesh); you wouldn’t achieve the detailed transition as the transition would be linear from one point to another.
That is, unless there’ a solution somewhere with shader coding.
Could you post some code of your method? it is a bit hard to me to understand without example.
Well, what I was suggesting initially was to store color with the coordinates of your verts. Vector4(x,y,z,w) where W is your colorID.
So it’d be something like this:
Vector4 vert; //do all your generation using this variable.
//When you’re ready to draw mesh:
int amount = vert.Count;
Color[ ] colors = new Color[amount];
var newVerts = new Vector3[amount];
for (int i = 0; i < amount; i++) {
newVert = new Vector3(vert.x, vert.y, vert_.z);
switch((int)vert.w)
{
case 0: //rock
colors = new Color(1,0,0,1);
break;
case 1: //grass
colors = new Color(0,1,0,1);
break;
default: //water
colors = new Color(0,0,1,1);
break;
}
}
/////
Then you’d need to write a shader that’d map specific textures based on the color of the vertex.
It’s crude and you won’t get any roundness from this (since you’d most likely line up your verts in a grid) so you’d get gradients in vertical, horizontal and diagonals._