Photonic and optoelectronic properties of layered semiconductors