To predict and mitigate for the degradation in physical and biologically effective dose distributions of particle beams caused by microscopic heterogeneities in lung tissue. Materials and Methods: The TRiP98 treatment planning system was adapted to account for the beam-modulating effect of heterogeneous lung tissue in physical and biological inverse treatment planning. The implementation employs an analytical model that derives the degradation from the established "modulation power" parameter P mod and the total water-equivalent thickness of lung parenchyma traversed by the beam. Beam modulation was reproduced through an on-the-fly convolution of the reference Bragg curve with Gaussian kernels depending on the modulation power of lung tissue (upstream). For biological doses, the degradation was determined by modulating dose-averaged 𝛼, 𝛽, and LET distributions. Carbon SOBP measurements behind lung substitute material were performed to validate the code. The implementation was then applied to a phantom and patient case. Results: Experimental results show the passage through a 20-cm Gammex LN300 slab led to a decrease in target coverage and broadening of the SOBP distal fall-off. However, dose coverage was regained through optimization. A good agreement between calculated and measured SOBPs was also found. In addition, a patient case study revealed a 3.2% decrease in D 95 from degradation (P mod = 450 𝜇m),which was reduced to a 0.4% difference after optimization. Furthermore,widening of the RBE distribution beyond the target distal edge was observed. This implies an increased degradation in the biological dose, which could be harmful to healthy tissues distal to the target. Conclusions: This is the first implementation capable of compensating for lung dose perturbations, which is more effective than margin extensions. A larger patient study is needed to examine the observed modulation in the RBE distribution and judge the clinical relevance also in IMPT, where margins might prove insufficient to recover target coverage.