Foliage and slope - intermediate between landscape normal and Z axis

Hi,

In the video of “from Ants to Outer Space”, there was a solution to solve the problem of foliage in slopes using a mesh with all the vertices with 0 in Z coordinate and a color map to extrude the height of the foliage.
Following this idea I’ve developped a material function for any mesh using the world position offset :

The result with the function enabled :

Without the function :

C&C are welcome

EDIT: I’ve tried an optimized version but I rollback, sorry for the multiple versions of my post

How is this different from align to normal or align to slope in the grass-settings panels?