How can I make my adjacent meshes' edges line up?

I have a terrain system that uses a grid of meshes, which increase and decrease in detail as the camera gets closer. However, when there is 2 different level meshes next to each other, this happens:
alt text

I want to have the high detailed mesh deform it’s edges so that the meshes line up. I figured that if I got every other vertex along the edge and made it’s y value the average of the 2 adjacent vertices, it would smooth out, but I have no clue how to program this.

Each mesh is just a quad (4 verts and 2 tris) that has been subdivided 3-5 times, depending on the detail level, and deformed based on a height map.

I have about 3 years of C# experience, but I’m relatively new to procedural meshes, so explanations and example code would also be appreciated greatly.

“if I got every other vertex along the edge and made it’s y value the average of the 2 adjacent vertices, it would smooth out”

Yeah, I remember doing some of this. What a headache! :wink:

What you’ve stated is the only solution with which I’m familiar.

OnAnyChangeInLOD…
ForEach pair of neighbors…
if different LOD…
Stitch()

Your stitch method takes two meshes, determines their relationship, and uses that relationship to determine which edge of each mesh to work on. Then, you’ve already figured out the algorithm for yourself! Just gotta make it happen! Good luck,