# How to do heterogeneous volume absorption using path tracing?

I want to do volume rendering using path tracing with a absorption only model. And my data is in a 3D grid, which is turned into a voxel medium in my renderer.

However, I can't seem to be correct implementing the algorithm.

According to this note (however absorption-only heterogeneous case is not mentioned here), the radiance at point $x$, direction $\omega$, with emission-absorption model in a homogeneous medium is:

$L(x,\omega) = \int_{x}^{y} \tau(x,x') \epsilon(x')dx + \tau(x,y)L_e(x,\omega)$

where $\tau$ is the attenuation, y is a point on surface, and $\epsilon$ is emission at point $x'$.

So I come up with the heterogenous, absorption-only equation as:

$L(x, \omega) = \tau(x,y)L_e(x,\omega)$

since I think the emission term should be omitted. However this equation seems not correct intuitively and do not give correct image.

According to this equation, the radiance at every point $x'$ along the ray within the volume is not counted, which is where I think the problem lies.

So what is the correct heterogeneous volume path tracing equation? How to derive the correct equation?

I give more details of my implementation here. The scene is simply a cornell box where only a voxel medium is inside the box. I trace a ray from the eye(camera), and the ray go through the medium and intersect a surface(the wall). To simplify the procedure, I set max_bounce to 1 which means the path is eye -> medium -> surface -> light.

So the value of this sample is simply the throughput of the medium times the throughput of the surface times direct light at surface intersection.

However I got the result image

Your equation for the absorption-only model is correct: You multiply the luminance $L_x$ at the surface by the transmittance of the participating media between eye and the surface. For homogeneous media you can calculate this analytically using Beer-Lambert law: $$L_y=L_xe^{-\mu|x-y|}$$ For heterogeneous medium you can calculate the transmittance by ray march through the medium using for example Woodcock tracking explained in the paper you referred.