The new generation of gamma-ray telescopes has revealed a rich sky at very high photon energies. The unveiling of the nature of these sources and the understanding of the physical processes that give rise to the gammaray emission are among the most important present challenges of high-energy astrophysics. To investigate these issues, the propagation and interaction of the emitted electromagnetic radiation, both within the source and during its journey to the observer, must be understood. In this work we describe the development of a tool to provide an accurate, ab-initio description of the propagation of gamma rays in astrophysical environments. We expect this tool to contribute to the understanding of the physics of cosmic gamma-ray emitters.