I think I should structure this question better.
I'm developing a procedural terrain structured with voxel chunks.
- contains a NxNxN voxel array generated with perlin noise 3d
- contains a Mesh derived from the surface points of the voxel array
- is rendered with marching cubes algoritm
Every mesh has its own Material
Every Material is made of 3 texture: one main texture and 2 minor textures to be blended with the main one depending on the slope. Every material has its own shader attached.
So I have a terrain made of a certain number of chunks, that are a certain number of meshes generated as the game launches. Inside every chunk blending if okay, since I have the only material for the current mesh I have only to blend its textures depending on heights - and this is done by the shader.
In this attached image
you can see quite clearly what I acheived until now. As you can see, everything is mostly divided in "squares", which are the meshes. Each square has a texture green or beige (grass or sand).
My concern is that: When passing from grass to sand there is no blending, i.e. blending between 2 meshes is my real problem, because inside the shader if have the surf function which iterates over all the input vertices. But those vertices are only from one mesh. To blend correctly I would need informations also about the vertices of the mesh nearby.
So the question is: how can I blend properly materials belonging to different meshes?