How to have a paint-ish effect on terrain/objects

Hello,
I am trying to acheive the following…


… where there is a line on the terrain or any object, that follows the y level of the object its on top of but doesnt go any higher.

Try this