Spatially nonuniform optical illumination of semiconductors containing metastable defects, such as GaAs:EL2 and DX-related defects in III-V and II-VI semiconductors, induces metastable photorefractive and free-carrier gratings. Detailed calculations of the space-charge gratings in these materials are made as functions of fringe spacing and optical exposure. In both defect cases a unique nonequilibrium Fermi level, obtained from a charge balance approximation, can be defined that describes the spatial charge transfer and the resulting modulation of the optical properties of the semiconductor, without resorting to multiple quasi-Fermi levels. The process of writing holographic gratings with low intensities is analogous to adiabatic modulation doping. The transfer of charge from photoquenched regions to nonphotoquenched regions determines the highest spatial resolution that can be supported in the materials. In the case of EL2, the modulation doping produces a p-i-p-i doped superlattice. The DX defects support smaller Fermi level modulation, but have larger optical effects based on persistent photoconductivity and free-carrier gratings. (C) 1996 American Institute of Physics.