A method for the calculation of three-dimensional dose distributions for high-energy photon beams is presented. The main features are (i) the calculation is fast enough to allow interactive three-dimensional treatment planning, and (ii) irregularly shaped or compensated fields, which are required to fit three-dimensional dose distributions to target volumes, are adequately taken into consideration. The method is based on the pencil beam convolution technique and shares its features concerning accuracy. A considerable gain in speed is achieved by decomposing the pencil beam kernel into three separated terms, thus reducing the required number of two-dimensional convolutions. The convolutions are performed in the frequency domain via the fast Hartley transform. Using these techniques, the calculation time for the convolutions is only about 8 s on a DEC VAX station 3100. This is one-fourth to one-third of the calculation time for the ray tracing through the three-dimensional CT data set, which has to be performed in any case. Results of the calculation are compared with measurements in a homogeneous phantom for 15 MV photons. Two irregular fields shaped with a multileaf collimator are considered. The deviations between measured and calculated absolute dose values are smaller than +/- 2%.