Diffraction gratings are common optical elements in spectrometers, fan-out gratings, dichroic mirrors, and other filter devices. One common aspect of all of these is that they split an incoming wave into multiple diffraction orders. The direction of the diffraction orders depends on the angle of incidence and period of the grating relative to the wavelength. This can be a difficult concept to grasp.
Here is a visualization of the direction of the diffraction orders as the angle of incidence is changed. There is a greater number of diffraction orders into the substrate because that region has a higher refractive index.
This is a visualization of the direction of the diffraction orders as the period of the grating is adjusted.
This is the same visualization, with an oblique angle of incidence.
This is a necessary concept to understand to design and simulate any periodic structure. For more details about diffraction gratings, check out our course on 21st Century Electromagnetics.