Terrain triangulation (part 4?)

This is getting to be almost a daily thing! The previous post is here.

First, a small note. The images I have in the previous post showed what a 4-to-1 grid-to-heightmap resolution looked like. However, it turns out that when we use weighted sample points from the heightmap, a 2-to-1 grid ends up giving nearly identical results.

So my task turned to how to implement the quad re-orientation on the GPU. While drawing some diagrams, wondering if I should implement the re-orientation at the grid level (in each 1×1 quad) or heightmap level (2×2 quad), I noticed that if I triangulate the quad as fixed alternating orientations:

then it actually contains all the triangle edges of any per-quad re-orientation at the coarse (1×1) level:

So perhaps I don’t really need any quad re-orientation – all the triangle edges are there.

However, using this triangulation, we end up with something like this:

You can see we still get the “wiggles”. This is because the “center point” of our group of 8 triangles (which cover a texel of the heightmap) is based on the average of the four nearby heightmap texels. If instead we detect the center point and “align” it along just the two texels which correspond to the terrain shape, we approach what we had before. This is basically the quad re-orientation done in the shader, except we don’t need to actually rotate anything. The result is blow:

It’s close, but it’s not perfect. One problem is that we’re doing this for height, but not normals (in my current implementation the normals are offset by a half texel). So there are still some artifacts (though they aren’t visible in this example).

Here’s another example of the difference when we “fix” the vertex so that it is aligned with the terrain (bottom image):

Remember the snow scene from last time? Now the comparison looks like this:

There is much less of a grid pattern now that I am aligning vertices to the terrain (there’s definitely some visible though, and that’s due to the interpolation of the normals). The difference in the amount of snow is due to the difference in my normal calculations.

Finally, another comparison showing a really bad case of texture projection artifacts with the original, followed by the “dumb” 2-to-1 grid resolution, followed by the “smart” 2-to-1 grid resolution with aligned vertices.

You can still see jaggies in the bottom image. Again, this is due to the  normals. I could probably hide this a bit by introducing some per-position noise on the flat/steep texture projection transition.


2 comments on “Terrain triangulation (part 4?)

  1. […] A (probably final) quick post about this. The previous post is here. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Space Quest Historian

Adventure game blogs, Let's Plays, live streams, and more

Harebrained Schemes

Developer's blog for IceFall Games

kosmonaut's blog

3d GFX and more


Turn up the rez!

bitsquid: development blog

Developer's blog for IceFall Games

Game Development by Sean

Developer's blog for IceFall Games

Lost Garden

Developer's blog for IceFall Games


Developer's blog for IceFall Games

Casey's Blog

Developer's blog for IceFall Games


Developer's blog for IceFall Games

Rendering Evolution

Developer's blog for IceFall Games

Simon schreibt.

Developer's blog for IceFall Games

Dev & Techno-phage

Do Computers Dream of Electric Developper?

- Woolfe -

Developer's blog for IceFall Games

Ferrara Fabio

Game & Application Developer, 3D Animator, Composer.

Clone of Duty: Stonehenge

First Person Shooter coming soon to the XBOX 360

Low Tide Productions

Games and other artsy stuff...


Just another WordPress.com site

Sipty's Writing

Take a look inside the mind of a game developer.

Jonas Kyratzes

Writer, game designer, filmmaker.

%d bloggers like this: