Design of cascaded gratings to be used in out-of-plane signal processing