We have demonstrated an original ultrafast laser beam shaping technique for material processing using a spatial light modulator (SLM). Complicated and time-consuming diffraction far-field phase hologram calculations based on Fourier transformations are avoided, while simple and direct geometric masks are used to shape the incident beam at diffraction near-field. Various beam intensity shapes, such as square, triangle, ring and star, are obtained and then reconstructed at the imaging plane of an f-theta lens. The size of the shaped beam is approximately 20 mm, which is comparable to the beam waist at the focal plane. A polished stainless steel sample is machined by the shaped beam at the imaging plane. The shape of the ablation footprint well matches the beam shape.