We present a first-principles investigation on the optical absorption of tungsten trioxide, an electrochromic material. Using state-of-the-art techniques, the absorption spectra are calculated for the cubic, monoclinic, and amorphous phases. For both crystalline and disordered structures, doping induces strong absorption in the infrared. Absorption in the visible range increases with the degree of structural distortion; the absorption coefficient in the blue exceeds 103 cm−1 at doping levels above 1020 cm−3 in the monoclinic phase. Increased disorder in disordered structures significantly enhances the visible-range absorption. We identify the microscopic mechanism as optical absorption originating at conduction-band-derived states that are filled by doping.