Note the black cracks between most of the patches. This is because most patches have a different morphing amount from their neighbors. So I had to figure out how to make the patches join together properly.
At first, I used skirts. A skirt "drapes around" the perimeter of a terrain patch so that it covers the cracks around each patch. I can see why many people here on gamedev.net don't like the idea of skirts. They are definitely a kludge. My biggest problem was determining how long to make the skirts. Too long, and you burn fill rate. Too short, and some cracks are not covered completely. I searched all over the intarweb but I couldn't find a good algorithm to determine skirt length without knowing the elevations of all adjacent points at LODs n + 1, n, and n - 1. (As you probably guessed, n is the LOD of the patch.) Yuck. Also, textures on skirts appear to be stretched vertically, so when you see a skirt, it generally looks like hell. So I gave up on them.
I think I found something that worked. In geometry clipmaps, each vertex has its own morphing amount, which is determined by the distance from the viewer. I'm using this idea in my terrain engine.
At first, it appeared to work, but some cracks occasionally appeared. It took me a while to find out the reason. When a terrain patch is split into four smaller patches, the vertices in these patches do not have the same morphing amount; this is because the morphing amount is determined by distance. Something similar happens when four smaller terrain patches are merged into a single patch. I modified the morph formula so that all vertices in the patches that are close enough to split have the same morph amount of 0.0 (finest), while all vertices in the patches that are far away enough to merge have the same morph amount of 1.0 (coarsest). In between, there is a linear blend between 0.0 and 1.0.
Here's a screenshot showing this in new morph forumla action:
The patches with the same color share the same LOD. The brightness inside of the patches indicates the morphing amount to use, where 0.0 (finest) is represented by a darker shade, while 1.0 (coarsest) is represented by a lighter shade.
Now here's a screenshot of the same normal-mapped terrain with the new morphing code:
Everything appears to work now. When flying around, it's kind of neat to see the terrain detail smoothly increase as you get closer.
Now the not-so-fun part:
Because I was experimenting with a lot of different terrain LOD techniques, most of the quadtree and rendering code is stored in a single file littered with global variables and other yucky things. I now have to clean up and document the code. Once I'm done all that, I'll have a terrain engine that I can play with. I can then begin to experiment with fun things like GLSL shaders. I can't wait!
I think this'll be my last journal entry for a while because I'm off to clean up and document the code! Bleah, I'll probably procrastinate and take until May to finish :-) And Metroid Prime Hunters comes out in a few weeks, so that'll be occupying some of my time.