Many imaging applications rely on sample illumination with known 3-D light distributions. As these 3-D light distributions must satisfy the wave equation, many variables such as the geometry and reflectance of the sample and its environment may cause changes. While in most applications this change is neglected, for many scanning applications where the scanning beam should preserve its characteristics over a large distance it could become significant. Moreover, the environment scatters may also be used to generate desirable 3-D light distributions that may not be realizable using a single optical element. We propose a method that provides a solution for an optical element which modulates a physical beam in the presence of discrete scatters. This solution will generate a beam with optimal 3-D distribution in comparison with a desired one in the sense of minimal mean-square error. Specifically, the proposed concept is applicable for enhancing photo-acoustic imaging where the projected photonic excitation patterns need to be obtained inside a body after passing through scattering biological tissue.