I think sometimes death doesn't detract at all. The problem is that the times it does detract from immersion are the times when it's most likely. Climactic events, boss battles, end runs, and so on all tend to be hard. But the moment I see the unexpected twist, feel betrayal, ready myself for the final confrontation and then die and reload the sense of part of epic events just goes.
For some reason I found it especially jarring in the Witcher 2, while fighting the kayran (the tentacle thing; not a clue how to spell it). It felt awesome. The I proceeded to die 5 times while I learned the fight. Fair enough, but by the 5th time, the atmosphere was utterly gone. When it pulled down the bridge, allowing me to reach the head and kill it, there was that -alright-now-you're-going-down-***** surge - until I failed to spot the patch up the rubble and died again. So yes I learned my lesson and killed it properly the next time, but by then the surge had been replaced by mild irritation.
For some reason I found it especially jarring in the Witcher 2, while fighting the kayran (the tentacle thing; not a clue how to spell it). It felt awesome. The I proceeded to die 5 times while I learned the fight. Fair enough, but by the 5th time, the atmosphere was utterly gone. When it pulled down the bridge, allowing me to reach the head and kill it, there was that -alright-now-you're-going-down-***** surge - until I failed to spot the patch up the rubble and died again. So yes I learned my lesson and killed it properly the next time, but by then the surge had been replaced by mild irritation.