Along an ray on which many xray photons are travelling, let $\mu(t)$ be the fraction of energy absorbed per unit length at position $t$ on the ray.
$\mu(t)$ depends upon the material at position $t$, and upon the wavelength of the xray photon.
Then the received xray energy, $I_\textrm{out}$ is
$\Large I_\textrm{out} = I_\textrm{in} \; e^{- \int_0^D \mu(t) \; dt }$
Proof:
A fraction $\mu(t) \; \Delta t$ is absorbed over distance $\Delta t$ at location $t$:
So the change in $I$ is $\Delta I$:
$\Delta I = - \mu(t) \; \Delta t \; I(t)$Moving to infinitesimal quantities:
$\begin{array}[t]{rl} dI & = - \mu(t) \; dt \; I(t) \\ \int_0^D {dI \over I(t)} & = - \int_0^D {\mu(t) \; dt} \\ \ln I(D) - \ln I(0) & = - \int_0^D \mu(t) dt \qquad \textrm{recall} \int {dx \over x} = \ln x\\ \ln {I(D) \over I(0)} & = - \int_0^D \mu(t) dt \\ {I(D) \over I(0)} & = e^{- \int_0^D \mu(t) dt} \\ I(D) & = I(0) \; e^{ - \int_0^D \mu(t) dt} \\ \end{array}$
If $\mu(t)$ is constant along the ray, the "fall off" is exponential: