What determines when the ball loses its shell or goes super-saiyan?

I've heard people claim it has to do with:

* How hard you hit the ball
* How many times the ball has been hit since it touched the floor last
* How high off the floor the ball is

Based on my observations so far, every one of these is incorrect. So what actually causes it?