I have a terrain with two materials going into a Mix Shader, I want the fac input to be the slope of the terrain. Steep parts should be one color, flat part another.
I have a variation to this, and depending on what you are doing, it may make sense to use one of these answers over the other.
You may need to use true normal, depending on if you are animating the object(s) in rotation for any reason, and anything in the world that would be rotated may need to keep its material selection to be at the top of the rotated object.
so same basic steps but slightly alternate node setup.
Here's The result.