An optical apparatus comprises a planar optical waveguide and at least one
set of diffractive elements formed in or on the waveguide. The waveguide
is arranged to confine propagating optical signals in at least one
transverse dimension. The diffractive element set collectively exhibits a
positional variation in diffractive amplitude, optical separation, or
spatial phase over some portion of the set. The diffractive element set
is collectively arranged to route, as an output optical signal, between
corresponding input and output optical ports, a corresponding diffracted
portion of an input optical signal. The diffractive element set is
collectively arranged so that the input optical signal or the output
optical signal is successively incident on the diffractive elements. The
diffractive elements are arranged according to an interference pattern
derived from computed interference between a simulated design input
optical signal and a simulated design output optical signal, the
interference pattern exhibiting said positional variation.