凍傷的體積整合


5

在SIGGRAPH 2015上的presentation中,Electronic Arts介紹了使用3D紋理與視錐面對齊的體積渲染方法。

此技術需要兩個步驟:

  • 將顏色和密度注入3D紋理中,
  • 沿紋理Z軸的積分。

集成代碼示例在幻燈片27上。但是,它被認為是錯誤的。有誰能解釋該代碼(完全標準的raymarching集成)出了什麼問題?

6

What is wrong with it seems to be explained on the next two slides: it leads to non-energy-conserving results, where the apparent brightness of the volume changes depending on the scattering coefficient.

My read of it is that the "wrong" integration code implicitly assumes a constant transmittance over the extent of each voxel. But the trouble is, when the scattering coefficient is high, the transmittance will fall off significantly within a single voxel. For instance, if you have voxels of size 10 cm, but the scattering coefficient is 1 / (5 cm), then the transmittance falls off by exp(10 cm / 5 cm), or about a factor of 7.4 over the length of the voxel!

Therefore, according to slide 28, a better approach is to explicitly account for the transmittance falloff over the voxel length, while still assuming constant inscattered light. Fortunately the integral has a simple closed-form solution. So, they're saying to evaluate that formula per voxel in the integration loop, in place of the former "wrong" one.

For completeness: in the code from slide 27, replace this line:

accumScatteringTransmittance.rgb += scatteringExtinction.rgb *
    accumScatteringTransmittance.a;

with this:

accumScatteringTransmittance.rgb += scatteringExtinction.rgb *
    accumScatteringTransmittance.a *
    ((1.0 - transmittance) / scatteringExtinction.a);

Here, accumScatteringTransmittance.a is the transmittance at the point the ray enters the voxel (i.e. the resultant transmittance of all the voxels in front of it), and then the ((1.0 - transmittance) / scatteringExtinction.a) factor accounts for the varying transmittance within the voxel.