How does landscape painting work under the hood?

When you paint one material on top of another in the editor, what is actually going on? I know it involves multiple channels for multiple materials in the shader, but how does it work? Is it creating transparency masks aligned to the UVs or something? What’s the difference between blending materials this way and doing it by hand in an external program like photoshop, etc?