/// <summary> /// Turns a plane's vertices into a segment of a sphere /// - Processes neighbour faces in order to remove gaps/tears /// </summary> /// <param name="face">The face in question (aint it an ugly one?)</param> private void FinalizeFace(TerrainPatch face) { if (face.finalized) { return; } var verts = face.mesh.vertices; for (int i = 0; i < verts.Length; i++) { // //verts[i] = verts[i].normalized * (scale + noise(verts[i], 2, 1.7f, 0.1f, scale / size)); //verts[i].y += noise(verts[i], 2, 1.7f, 0.1f, 10); float hs = scale / 2; //float u = (verts[i].x + hs) / scale; //float v = (verts[i].z + hs) / scale; //verts[i].y = heightmap.GetPixelBilinear(u, v).grayscale * 20; verts[i].y = GetHeightAt(verts[i].x + hs, verts[i].z + hs) * heightScalar; } face.mesh.vertices = verts; face.mesh.RecalculateNormals(); face.mesh.RecalculateBounds(); face.Texturize(); face.filter.sharedMesh = face.mesh; //face.collider.sharedMesh = face.mesh; face.finalized = true; }