The technique described here is often referred to as the z-pass technique. It has one fatal flaw. If the camera is located within a shadow volume, this technique breaks down because the counts in the stencil buffer will be off by at least one. A common solution is to basically invert the problem and trace a ray from infinity toward the view point. This is called the z-fail technique or Carmack's reverse.
Care must be taken when using z-fail because it is important to draw the caps of the shadow volumes. However, the technique is very similar to z-pass. Instead of incrementing/decrementing when the depth test passes, we do so ...