Nice one, seems you at least got a vertical wall going right, didn't work with my tests.

I have updated the main post with a new version the problem with non squared terrains is hopefully fixed I tested it with a 2x1 and included an example heightmap for it