Phase stepping for differential phase contrast and/or dark field x-ray imaging using a switchable grating in which particles in a reservoir are aligned into wall-like x-ray absorbing structures by inducing a standing wave in a medium in the reservoir. The standing wave is modified by a second ultrasound generator that modifies the standing wave such that the pressure nodes of the first standing wave shift position.