An apparatus for processing material with focused electromagnetic radiation, comprises: a source emitting electromagnetic radiation, means for directing the radiation onto the material, means for focusing the radiation on or in the material, a unit for generating a pattern in the optical path of the electromagnetic radiation, an at least partially reflective surface in the optical path before the focus of the focused radiation, said pattern being imaged onto said at least partially reflective surface through at least part of said directing means and said focusing means, at least one detector onto which an image of the pattern is reflected by said surface and which generates electrical signals corresponding to said image, said image containing information on the position of the focus, a computer receiving said electrical signals and programmed to process said image so as to generate an electrical signal depending on the focal position, and a divergence adjustment element arranged in said optical path and adapted to receive said electrical signal of the computer so as to change a divergence of the electromagnetic radiation depending on said signal.