Fabrication of grating structures with variable period