A diffraction grating comprises a substrate with a set of protruding ridges and intervening trenches characterized by a ridge spacing Lambda, width d, and height h. The substrate comprises a dielectric or semiconductor material with a refractive index n1; the first substrate surface faces an optical medium with a refractive index n2 that is less than n1. Each ridge has a metal layer on its top surface of thickness t; at least a portion of the bottom surface of each trench is substantially free of metal. Over an operational wavelength range, lambda/2n1<;Lambda<;lambda/(n1+n2) can be satisfied. An optical signal can be incident on the diffractive elements from within the substrate at an incidence angle that exceeds the critical angle. The parameters n1, n2, Lambda, d, h, and t can be selected to yield desired polarization dependence or independence of the diffraction efficiency.