Vertex Mask based on world Z axis?

Hi, I was wondering if I could get help setting up a vertex mask (in my material) that is based on the world z axis. For example I would like to have the base of my object be set to 0, black and the top of the object to be set to 1, white. I’m trying to make foliage sway more at its tip.

So far I have been creating custom vertex masks but it hasn’t been a good option for everything, I believe using the world axis will make things sway more uniformly.

Thank you very much!