Alternative rivers/lakes

Started by bigben, March 25, 2007, 08:19:43 AM

Previous topic - Next topic


Inspired by the rivers posts recently I set about trying to insert some rivers into my projects, using a simlar approach to that used by others to date, but incorporating my existing masking methods.

<edit>An updated test render with some very basic surfacing. Working with DEM data, you can also do lakes with this method BUT you have to be careful to only place water where it should be. In the bottom right lake you can see some glitches on the far shore where the lake surface extends up on to the bank (due to automated colour selection being too broad).

Also, by default TG2 adds fractal detail to a terrain file. This should be turned OFF for loaded TER files to keep the lakes surface flat. Fractal detail can still be added to the terrain with its distribution controlled by an inverted mask used for the rivers/lakes</edit>

The end result uses a single image map to create both the river bed and then fill it with "water".  The level of control provided by the nodes used is reasonably precise, and provides better control than my previous lake model (which will now be replaced with this one).


The other advantage, given that DEM data has flat lake surfaces, is that it is possible to use a single mask and lake to create all of the rivers and lakes in the entire project regardless of their altitude. This simplification means I can concentrate entirely on the mask to add as many lakes as I can find in the original satellite image without any extra work at all to add them to the TGD.

The attached TGD also has a rough fake stones shader for the river bed/bank.

displaced terrain for river bed

Equal reverse displacement filling river bed with water.
(Top render has a 1m drop to river)

Terrain and image not included.

Tweaks to mask edge (affects mask sharpness and steepness of river bank) are via the two colour adjust shaders, particularly the white point.  It is important that white point of wide mask < white point of narrow mask.

Linking the mask to the water opacity prevents render glitches putting water in areas outside the mask.

If you make any improvements to this please let me know as well ;)


  • river_test.tgd: Single image mask used for both rivers and lakes
  • lakes_and_rivers.tgd: Rivers added as above, but lakebeds added via a separate mask and then "filled" with a separate lake shader for each lake. This file is intended for terrains where the lake surface on the terrain is not actually flat. Extra info and a full demo posted in


More to learn.  This is like browsing an encyclopedia.  Thank BigBen!
So this is Disney World.  Can we live here?


While working on a new version of my Tetons project I noticed that the lake surfaces still looked a little off. Added a note to the original post to remove fractal detail from loaded TER files to keep lake surfaces flat.

I also added an image of the heightfield to my PSD reference image to check that rivers weren't going up onto slopes where they shouldn't be as a result of automatic colour selection in the landsat image being to broad. This has made it much easier to check for errors prior to rendering.


One more thing specific to this approach... the wave size has to be taken into account when calculating how far to "raise" the water surface above the river bed.

Actual displacement = desired displacement - wave scale

If the combined displacement plus wave size is too big you will end up with a water surface floating above the ground.

I think I'll go back to adding TG lakes for my lakes simply to reduce the amount of fine tuning of the mask image required to correctly place the water on the lake surface.  You can get away with excess rocks on the edge of a lake, but water running up a bank has to be fixed. The lake beds and water opacity masks can still be derived from a similar set of shaders in most cases


I turned off fractal but still the underlying terrain features appear on the water.  How can I set this up so the water is flat?


The water surface is applied to the underlying terrain. The reason my lakes are flat is because the terrain is derived from 10m DEMs which have flat lake surfaces. The result would not be as good fom 90m SRTM data because this has a significant amount of noise.

In theory if the terrain is not perfectly flat in the regions where you want lakes, then you could split the shaders up so that you have a mask for the downward displacement of the river/lakebeds, a mask for the upward displacement for the rivers, and then add a TG lake to each lakebeds that you've created.

For practical reasons it would probably be best to use separate masks for rivers and lakebeds, as you also use the same masks to restrict the water surfaces. This avoids having a lake surface floating above a river flowing out of a lake.

I'll be doing this for my current project and I'll post another file with a small TER and masks when I get around to it.


There aren't any rivers, just one giant lake in the valley.  I like your shader because it seems to smooth the shore of the lake evenly to the water edge, or is the lake image map masking the opacity of the water object?

I look forward to your example file.  Meanwhile I'll keep at it and post results if it works.


Quote from: gregsandor on April 09, 2007, 03:36:16 AM
There aren't any rivers, just one giant lake in the valley.  I like your shader because it seems to smooth the shore of the lake evenly to the water edge, or is the lake image map masking the opacity of the water object?

This is because water surface uses the same mask as the river/lake bed. The width and slope of the bank are controlled by the difference in displacements for the water and river bed, and the differences in the colour adjust shaders.  The main reasoning behind this approach is that it's easy to ensure that the water doesn't spill out into unwanted areas.

The alternative version with separate lakes is now posted.


An extra tip for those using GlobalMapper....  The slope shader in GM is a very useful addition for selecting rivers and lakes from DEM data.  I generate my masks from a multilayered PSD file with an elevation image (rendered using lighting effects), a landsat image and an image using the slope shader.

The slope shader is very useful for selecting lakes as they're white and usually surrounded by a thin bank. It's also useful for checking that rivers don't go up a steep bank which can happen with small alignment errors in the landsat imagery, or in areas where deep shadows make it hard to see the path of the river. It also makes it easier to find the floor of a valley for manually drawing in rivers in reasonably realistic locations.

Previously, the render below had the river going up the banks at the apex of each bend