There's kind of three things going on, actually:
- Doping
- Layers
- Patterns
Doped semiconductors actually reflect light differently. I can't find a reference for it (go figure, searching for basic physics only turns up current high-level articles
![Face Palm :palm:](https://www.eevblog.com/forum/Smileys/default/xfacepalm.gif.pagespeed.ic.EBDwh1hCfo.png)
) but it's something about the light's interaction with the carrier type and density, causing a phase or polarization shift, and therefore causing interference with the incident light. There's an optical hall effect which might be what I'm thinking of, which is also affected by ambient magnetic fields as the name suggests.
Layers of semiconductor, oxide and etc. transmit light at different velocities, and are used in varying thicknesses, leading to simple interference colors.
Patterns, when periodic and finely etched (comparable to the wavelength of light), create diffraction gratings -- light is reflected from each wire in a bus, say, which when evenly spaced, causes interference at different angles -- a rainbow is reflected. We don't see much of this on small devices (few features to reflect light) or large pitch devices (features are widely spaced), but it's why CDs, EPROMs and etc. are so colorful.
Note that interference depends on angle as well, as a glancing angle travels farther through the material. So you generally get a play of colors over the surface of e.g. a microprocessor, but the exact rate (spectrum and angles) at which the colors are reflected varies by region.
A microprocessor is a good example, containing all of the above: well, probably not much visible semiconductor unless it's a quite old one, but periodic structures such as mask ROM, register files or caches, and buses, tend to show off all sorts of diffraction patterns, while "random logic" regions are more chaotic and have a noisy or speckled appearance.
Tim