\begin{algorithm}[t]
	\caption{\label{alg:deltaL}
		 Monte Carlo estimation of $\Delta\Lv$
	}
	\begin{algorithmic}[1]
		\Function{deltaRadiance}{$\bx$, $\dbx$, $\bom$, $\dbom$}
			\If{$\bom$ corresponds to a boundary/silhouette edge}
				\Comment{\eqref{eqn:rte3d_deltaL_silhouette}}
				\State Calculate $\dist^-$, $\dist^+$ using Eq.~\eqref{eqn:rte3d_d_lims} \label{alg3:line:case1_start}
				\State $\dist^{\mathrm{near}} \gets \min(\dist^-, \dist^+)$, $\dist^{\mathrm{far}} \gets \max(\dist^-, \dist^+)$
				\State $\bx^{\mathrm{near}} \gets \bx - \dist_{\mathrm{near}}\,\bom$, $\bx^{\mathrm{far}} \gets \bx - \dist_{\mathrm{far}}\,\bom$
				\State $\Delta\Lv \gets -\Ls(\bx^{\mathrm{near}}, \bom)$ \Comment{side path}  \label{alg3:line:sidepath_1}
				\State Draw free-flight distance $\tau$ from $\bx^{\mathrm{near}}$ with direction $\bom$
				\State $\tau \gets \tau + \dist^{\mathrm{near}}$
				\If{$\tau < \dist^{\mathrm{far}}$}  \label{alg3:line:sidepath_2_start}
					\State $\bx' \gets \bx - \tau\bom$
					\State $\Delta\Lv \gets \Delta\Lv + \frac{\sigS(\bx')}{\sigT(\bx')} \, \textsc{inScatRadiance}(\bx', \bom)$
						\Comment{Alg.~\ref{alg:inScatteredRadiance}}
				\Else
					\State $\Delta\Lv \gets \Delta\Lv + \Ls(\bx^{\mathrm{far}}, \bom)$ \Comment{side path}
				\EndIf  \label{alg3:line:sidepath_2_end}
				\State $\Delta\Lv \gets \trans(\bx^{\mathrm{near}}, \bx)\,\Delta\Lv$
				\If{$\dist^- < \dist^+$}
					\State $\Delta\Lv \gets -\Delta\Lv$
				\EndIf  \label{alg3:line:case1_end}
			\Else \Comment{\eqref{eqn:rte3d_deltaL_sharp}}
				\State Calculate $\gnorm^-$ and $\gnorm^+$ \label{alg3:line:case2_start}
				\State $\Delta\Lv \gets \Le(\bx_0, \bom \;|\; \gnorm^-) - \Le(\bx_0, \bom \;|\; \gnorm^+)$ 
				\State Draw $\bom'$ with probability $p(\bom')$
				\State $\Delta\bsdf \gets \bsdf(\bx_0, -\bom', \bom \;|\; \gnorm^-) - \bsdf(\bx_0, -\bom', \bom \;|\; \gnorm^+)$
				\State $\Delta\Lv \gets \Delta\Lv + \Ls(\bx, \bom')\,\Delta\bsdf/p(\bom')$ \Comment{side path}
					\label{alg3:line:case2_end}
			\EndIf
			\State \Return $\Delta\Lv$
		\EndFunction
	\end{algorithmic}
\end{algorithm}
