Skip to main content
add code sample
Source Link
Nathan Reed
  • 25.3k
  • 2
  • 69
  • 111

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.

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.

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.

Source Link
Nathan Reed
  • 25.3k
  • 2
  • 69
  • 111

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.