Traditionally, the shaping of non-uniform dose distributions has been performed by using wedges or compensating filters. The advent of high resolution multileaf collimators may largely eliminate the need for material attenuators for modification of the beam. This is achieved by a new technique for the shaping of arbitrary dose distributions by dynamic motion of the collimator leaves. By employing narrow elementary slit beams that correspond to the smallest possible opening of the multileaf collimator, the optimal density of such slit beams, i.e. opening density, can be determined automatically using a newly developed inversion algorithm. The present method has two major advantages: (1) internal structures in the field can be created, controlled solely by steering the collimator leaves, (2) the opening density determined by the algorithm never gives rise to underdosage: this is important from a radiobiological point of view.