A crucial aspect of PIXE/XRF analysis is accurately modeling the behavior of emitted X-rays as they traverse the sample, significantly influencing the intensity and detectability of the X-rays. This study presents a comprehensive simulation program designed to model surface topography and calculate X-ray path lengths in 1-D, 2-D, and 3-D views of samples. The model is applied to Micro-PIXE analysis and integrates key physical parameters, including stopping power, X-ray production cross-section, photon attenuation, and local photon creation to estimate the correct X-ray intensity map. Additionally, the simulation accounts for severe surface roughness, where X-rays may exit and re-enter the sample multiple times along their trajectory toward the spectrometer. The X-ray path length and its effect on the accumulated X-ray yield are calculated on both mathematical surface topography and experimental data obtained from Micro-PIXE using a four-segment silicon drift detector (SDD), revealing a remarkable correlation that underscores the importance of detailed X-ray path length calculations. By demonstrating the impact of path length on the accumulated X-ray yield for rough surfaces of varying microscale, this approach could enhance the accuracy of X-ray intensity predictions, leading to more precise elemental composition analysis in X-ray spectroscopy techniques.