Neal Templin in his Wall Street Journal's Cheapskate musings tries to sort out in Tipping Point: What It Takes to Make Your Waiter Like You what it takes to do the right thing.
Thankfully or not in a previous life he got his hands dirty in the restaurant business so at best he is ambivalent about tipping for bad service.
Related: To Tip or Not to Tip…Stingy or Over the Top…From Russia to Australia