When I was younger I was told that in extenuating circumstances one can rip toilet paper on shabbos (preferably not on the perforations) due to kavod ha'brios. This concept is applied in other places such as the way we hang a corpse who has been killed by beis din. What are the halachik parameters for this concept and how far does it extend? For instance if the bathroom were dark could one turn on a light or light a candle (malacha m'deoraisa) because of kavod ha'brios? Can a person be m'vater on their kavod ha'brios (some extreme practices such as rolling in the snow naked come to mind)?
If you have the sources for the above cited halachos please post