Layering materials on an object based on texture painting
Yes, this is how you can accomplish this - and the repeated color mix nodes will allow you to mix several material node trees together. You can also add to the effect by plugging the black and white image into a Bump node and feeding that into the normal of the shader if you are wanting to create a layer at the edge of the material boundary.