Procedural foliage and material mask

Hi! There are plenty of tools to pain foliage now, but I guess I stuck into specific situation. I have static terrain mesh, and I have texture mask, which I want to use as spawn area volume for the trees.

Guess I am out of luck? No build-in tools can help me to do this? I don’t mind a bit of extra coding, but no matter how I approach this, I can’t think of something which will not need me to dive deep into editor sources.