There have been various postings in this forum, none of which gave me what I needed, so I experimented myself.
The problem is: Export any terrain (not just a heightfield) as a heightmap image (i.e. a greyscale image with colour == altitude).
The solution I came up with, and which might be useful for someone else is this:
Use a Distance Shader.
Create two cameras. Both must have the same coordinates in X and Z. Set one (I call it "distance") to 0 in Y and rotate it 90/0/0. Set the other to some arbitrary high Y (higher than your terrain), like 5000 or so. Set this to orthographic and rotate it -90/0/0.
Now on your terrain shaders, add a Distance Shader. Use the "distance" cam as its point, and use Z (planar) as the method. Set the near and far distances so it works for your terrain (leaving near at 0 and setting far to the max displacement of your terrain seems to work fine).
This should give you a nice altitude-dependent shading, and if you render it (shadows off, sunlight off, atmosphere off) with the ortho camera, you get a heightmap at any point of your terrain you want, in any resolution you want.
I use this to have both a heightmap I can use in a 3D game engine and a beautiful TG2 render of the same terrain.