Plains Terrain: Part 2 - How not to Stitch

We last left off having just figured out how to render the squares of terrain in a proper grid. Now we have a different problem. If you look at what our terrain looks like now, you'll see that it's almost as though there is a border of vertices around each of the squares of terrain. I need these vertices to stitch the terrain together, and I need to figure out why they're way down at value zero.

Turns out my heightmap wasn't big enough by one pixel. That was an easy fix, now there are no random vertices floating out of place. Yet.

I'd like my terrain to be mostly uniform as it changes from place to place, instead of what I have now where everything looks completely disjointed. So, I added a global heightmap. When the program generates each individual heightmap, it uses the bumpiness value of the global heightmap in that specific location, and it looks awesome. Unfortunately, I forgot to take a screenshot here for some reason.

Even though it apparently looks good, it's predictable, so I'm gonna try and make the heightmap smaller, so there is more variation. That..kind of works, but it didn't actually change that much. I might try another noise generator other than Perlin noise, but not right now. For now, let's try some stitching.

I'm going to try and average the vertices in the top of one square and the bottom of another, so they should meet in the middle. I do that and...nothing happens. What is going on here?

After a few minutes of pounding my head against the keyboard, I remember I'm using VBOs (Vertex Buffer Objects) to render my data. Essentially, I'm using a shortcut in OpenGl to have my graphics card render the vertices instead of my CPU. Using VBOs also deals with messy things like frustum culling and stuff. Turns out when I say to stitch the vertices together I'm just changing a variable, not what OpenGl uses to render the vertices. I have to update the list that's in OpenGl's memory from the variables I'm changing.

That's not hard to do..and it's still not working. Well, it's working, but it's not getting the correct vertices from the squares.

After thinking about it for a while, I figured out why I wasn't getting the correct vertices. Let's just say that it is how I deal with the adding the vertices to an array, I'll not bore you with the details.

Well, it's not perfect, but it's better than before. I'm not quite sure why the gap is happening, but I'll figure it out eventually. At least I understand how I store my vertex data now.

The next day, I decided that I'd try solving this from a different angle. Instead of trying to stitch the terrain together, what if I just made one huge piece of terrain?

Damn, that looks nice. It's also the same number of vertices in the smaller terrain sections, I just spread out the distance between the vertices. So, let's try having a few squares of these, as I actually want a large amount of terrain, even more than this.

The stitching works how it did before, with that odd gap in the middle of the vertices, but it does look a little better being spread out more.

I like how this large terrain looks, I'm gonna keep it. I'm going to have to fix the stitching, obviously, but this should work.


Post a Comment