Blending Heightfields

One of my goals for Terragen 2 is to model an entire fantasy world.  There are a few approaches around the Planetside forums, but none offer the realism and control I’m looking for.  I want to be able to specify a “zoomed out” model, and also a more detailed model for specific areas when you zoom in (e.g. show villages complete with buildings).  I’m looking toward the long-anticipated API and my programming skills to do that.

In the mean time, I’m learning.

One challenge in creating a world-scale model is that not all areas look alike.  Green fields, desert, rocky hills all coexist in the same world and have to blend realistically from near and far.  This post explores how Terragen 2 supports that.

The files for this post are here.

Open up MergeShaderRedGreen.tgd.  There you will find two heightfields (one red, one green) merged together with a merge shader.  The heightfields have not been generated yet, so the areas appear flat.  They are designed to overlap.  Note how the overlap area is a blend of the red and green colors… it is yellow.

Red and Green Heightfields (not generated)

Red and Green Heightfields (not generated)

Now generate the heightfields and note how the two heightfields interact.

Here’s the generated result

Red and Green Heightfields (generated)

Red and Green Heightfields (generated)

Note how both the colors and the heights blend in the overlapping region… colors are a mix of the color of the two heightfields, and the altitude is the addition of both heighfields.

This example is constructed to understand how multiple heightfields in the same TGD interact.  With a little work, the red area could be desert, the green area plains.  Toss in an altitude shader to make the higher area in the middle snow-covered and the result would be quite a bit more realistic.

Advertisements
This entry was posted in Shaders. Bookmark the permalink.

One Response to Blending Heightfields

  1. bobbystahr says:

    great demo/explanation

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