Let It Snow! Using the Altitude Shader

Shaders are at the core of many of the cool things you can do with Terragen 2.  Simply put, a shader colors the pixels on the landscape using some sort of formula.  There are many different shaders that offer many different formulas.

Today we’re going to have a look at a shader that can color terrain based on the altitude of the point being drawn.  The Surface Layer shader can do just that.

NOTE: Download the Terragen 2 project file used for this post to follow along.

In this project I’m using a “hill” that has a special shape known as a Gaussian curve.  For now it’s only important to know that this kind of curve looks a lot like a hill but is very smooth, making it easier to visualize certain concepts.  The “hill” shape comes from a heightfield included in the download called Gauss.ter.

Let’s put some snow at the top of our hill, and have the grass run up the side a bit.  To get that picture, we’ll use three shaders.

First, the Base colours shader will provide the “dirt” color.  Select it, and change the Colour tab to pick a good dirt color.  Make sure Apply colour is checked.  Everything that is not explicitly shaded by another shader will get the base color.

Now have a look at the Surface layer (Grass) shader (renamed from the default Surface layer 01).  If you’re not using the provided project file, you would add a new Surface layer using the Add Layer button.  Set the Colour to a nice, grassy green.  Have a look at the Altitude constraints tab.  Get the grass to go up the mountain 1000 meters by checking Limit maximum altitude and entering 1000 for the maximum and 0 for the fuzzy zone.  We’ll look at what the fuzzy zone does in a bit.

Time to add some snow now.  The steps are pretty much the same as for the grass shader, but instead check Limit minimum altitude with a value of 3000, and pick a light gray color for the snow.

Here’s our first result

This looks like a shaded mathematical curve, not a hill.  By default Terragen 2 adds fractal detail to imported heightfields.  I turned off that fractal detail for the first landscape picture.  Let’s turn it back on now.

Notice the bumps.  We’ll cover fractals in much greater detail in future posts.  For now, let’s see what happens if we double the strength of parameters that drive the shape of the fractal

Our pictures show a pretty sharp line between the grass and the dirt, and between the dirt and the snow.  In real life, there’s never a sharp dividing line.  Remember the fuzzy zone parameter we set to zero? That parameter let’s us decide how many meters wide we want to transition to be from one shader to another.  Change those parameters to 500 meters and we get nice transition zones

In the next post, we’ll have a look at using the Slope constraint tab of the same  shader.

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

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