Realistic Rivers

Need a River?

This post describes a method to create realistic rivers by combining L3DT and Terragen 2.

The basic idea is to use L3DT’s ability to model water flow patterns using the RainMaker plugin (see also this post for a correction to the documentation) and then export those patterns into a separate height map.

The Steps

In L3DT

Design Map

Create a new project. On the design map, ensure there’s an area that should naturally channel water downhill. Starting near a peak, edit a path down the hill/mountain toward the ocean or lake that the river should flow into so that:

  • The altitude of each tile closer to the destination is lower than the previous one.
  • The tiles that form the banks of the river are higher than the river tiles

Example:

Height map

Go ahead and generate the Heightmap.

There’s a generally good path down the mountain.

Now use the heightfield editing tools in L3DT to carve out a clear channel for the river.

Water Map

Now use the Calculation wizard to create the water map

Install the RainMaker plugin from the link at the top of the post. You need to explicitly load the plugin

Run a script to create the river map

calc.WM.rain <GetMap “HF”> <GetMap “WM”> 1 500 0 -0.5 0xFF
calc.HF.ShiftMap <GetMap “Rain-maxdepth”> -5 false
calc.WM.ApplyOverlayMax <GetMap “HF”> <GetMap “WM”> <GetMap “Rain-maxdepth”> true


The RainMaker will take a while to run. Warning: The progress bar might get lost if you minimize L3DT. I got it back by minimizing and restoring a few times.

Water Map Mask

We’re going to need a mask in TG2 for the water areas (both to mask the separate heightfield, and to mask a water shader). Let’s define an appropriate mask algorithm in L3DT

Go to the Water depth tab and set a minimum depth of 1. Leave all of the other settings alone. Click Save as and give it an appropriate name (I used WaterHeightMask).

Have a look at the Rain-flow tab

Now convert the rainfall map to a height map

Turn off Include sea (bool) by double-clicking it

Now have a look at WM_Height

Finally in L3DT, we need to create a mask for the water…

Note: WaterHeightMask was created in a previous step.

Now create the Texture Map to give us a head start texturing the TG2 scene:

Finally, to prepare for TG2, export the following from L3DT

  • Heightfield as HeightMap.ter
  • Texture map as TextureMap.jpg
  • WM_height as WaterHeight.ter
  • Mask1_WaterHeightMask as WaterHeightMask.bmp

 

In Terragen 2

Create a new project. Delete the default Heightfield generate 01 and replace it with a new Heightfield load node. Load HeightMap.ter with it.

Add an Image map shader.

Have it use TextureMap.jpg.

Set the Projection type to Plan Y and the Size to 10240×10240 (because the texture map is 1024×1024 and I set L3DT to a scale of 10m/pixel).

Here’s what it should look like so far:

Add a Surface layer

Delete the Fractal breakup that is created by default. Uncheck Apply color on the Surface layer and add a Water shader.

On the Surface layer, go to the Displacement tab and assign a new Heightfield shader that loads WaterHeight.ter. Turn off Fractal detail for this Heightfield shader.

Still on the Surface layer, check Blend by shader

Assign a new Image map shader.

Navigate around the TG2 scene so that the camera is looking at the river and do a test render.

The water height can be adjusted up and down easily using the Surface layer‘s Displacement offset feature. Moving it down (e.g. to -1) moves the whole water level down a meter.

 

Use WaterHeightMask.bmp as the input to the new Image map shader.

Edit the new Image map shader to project Plan Y and cover 10240×10240 (if you used a heightfield of 1024×1024 with a 10m resolution)

Here’s my first test render. If you don’t like how the water flows, just go back to L3DT, edit the heightfield, and repeat the steps above (it looks like a lot the first time thorough, but it’s pretty easy once you get the hang of it).

 

 

 

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

One Response to Realistic Rivers

  1. dhruva says:

    Awesome

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