Blend materials based on displacement height

Is there any way to blend multiple materials based on their displacement height?
I mean material which is “higher” is visible over material which is “lower”…

Using water level maybe?