This is a very useful shader example.

You can do it also in the fixed function pipeline, but then you would need two passes for the terrain. Your shader code is faster, however a two-pass fixed function technique could be used as a fallback.