1. An optical apparatus, comprising: a substrate that propagates optical signals in at least two spatial dimensions, the substrate having a first port and a second port; and a plurality of diffractive elements collectively arranged within the substrate so as to exhibit a positional variation in amplitude, optical separation, or spatial phase over some portion of the substrate, wherein: each element of the plurality of diffractive elements is individually contoured and positioned so as to preferentially route a portion of an optical signal between the first and second optical ports as the optical signal propagates within the substrate; and when a first optical signal having a first spatial wavefront and a first optical spectrum is introduced through the first port, the plurality of diffractive elements i) collectively applies a transfer function to the first optical signal to produce a second optical signal having a second spatial wavefront and a second optical spectrum, wherein the first spatial wavefront differs from second spatial wavefront and the first optical spectrum differs from the second optical spectrum, and ii) routes the second optical signal through the second port.