id Software has released the source code of Doom 3 under GPL license. You can download it from this page: Doom 3 GPL source release @ github.
This source code should contain the new version of stencil shadow volumes algorithm rewritten by John Carmack due to some legal issues:
Lawyers are still skittish about the patent issue around “Carmack’s reverse”, so I am going to write some new code for the doom3 release.
An example of stencil shadow volumes (GeeXLab)