I have this script that deforms a plane mesh to create ocean waves. Then I tiled a 10x10 grid of those planes to create the entire ocean for my world.
Problem is, I need the edges of each tile to line up with its neighbor, to provide the illusion of a seamless ocean, so that the player can transition from one tile to the next without noticing a difference.
Can you please suggest how you would accomplish seamless tiling? I am willing to redo the entire system if needed.
var scale = 10.0;
var speed = 1.0;
var noiseStrength = 4.0;
var noiseWalk=1f;
private var baseHeight : Vector3[];
function Update () {
var mesh : Mesh = GetComponent(MeshFilter).mesh;
if (baseHeight == null)
baseHeight = mesh.vertices;
var vertices = new Vector3[baseHeight.Length];
for (var i=0;i<vertices.Length;i++)
{
var vertex = baseHeight[i];
vertex.y += Mathf.Sin(Time.time * speed+ baseHeight[i].x + baseHeight[i].y + baseHeight[i].z) * scale;
vertex.y += Mathf.PerlinNoise(baseHeight[i].x + noiseWalk, baseHeight[i].y + Mathf.Sin(Time.time * 0.1) ) * noiseStrength;
vertices[i] = vertex;
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
}