Geometry nodes: How to distribute points on valleys only?

I want to add vegetation to my rocky semi-desert scene of Himalayan mountains, using geometry nodes. In that scenery, vegetation only grows in valleys, where water would sometimes flow. Note that by 'valleys' I mean:

1. Slopes between hills.
2. Flat surfaces in various heights, surrounded by mountains.

The OPPOSITE of the tree distribution in this picture:

How do I do that procedurally, meaning without weight painting the valleys by hand? I tried to find some vector math trick, but failed to do so. Please help!

A few more simplified examples:

In the image above, the bottom area will be chosen, since it's flat and has a higher surrounding.

In the image above, the crevice at the center will be chosen, but not the flat slopes that wrap it.

In the image above, the normals are shown. The left side will be chosen, and the right side will not. This is because the normals meet each other only on the left side. How do I achieve that?

• I think you can detect the normals "meeting" each other using the dot product (or by computing the angle formed between them explicitly, if you prefer, using its geometric defn: en.wikipedia.org/wiki/Dot_product#Geometric_definition) If you combine that with some kind of threshold that only checks for "overlapping" normals that are sufficiently close to one another (in Euclidean distance), that would I think approximate what you want to do. I suspect the best way to generate a weight map like this will be to write a Python script to generate it Sep 28, 2021 at 23:11
• As an alternative to the use of normals like this, you could also consider, if you have to write a script anyway, just computing the gradient directly, and looking for places where the gradient changes signs in at least one dimension. I think this would correspond to 'valleys' Sep 28, 2021 at 23:12

The valleys and flat areas where things grow can be identified by a combination of the normal and the curvature of the mesh. Geometry Nodes can distribute plants to follow this pattern.

For example, given this geometry:

The terrain normal in the Z direction is:

The curvature for the terrain is:

Details for Blender 2.93.4