Working in Evee, I finally created a node setup in the shader editor which mixes grass and dirt by angle (grass on level - dirt on slopes) and it also lets me paint in trails and roads in texture painting.
But then I noticed that the road painting disappears in cycles, leaving only the slope. I am attaching a photo showing the two (Evee on top) as well as a photo of the node setup. I would like it to work in both render engines.
Probably not the issue causing your road mask to not work in Cycles, but for energy conservation reasons you shouldn’t use add shader node in this case at the end. It can result in the surface reflecting off more light than it receives.
It’s generally better in Eevee to handle mixing / masking via the color inputs before any surface BSDF and then feed the outputs of that into one output BSDF.