# Like 0Likes Dislike A Simple and Inexpensive Ray-casting Effect

model transmittance include this intensity algorithm number accumulated volume
This snippet describes two simple implementations of the emission/absorption model for participating media with ray-casting on the GPU

1 Introduction
This article describes two simple implementations of the emission/absorption model for participating media. The model is evaluated per-pixel with ray-casting on the GPU. In addition to the obvious (and quite inflexible and ineffective) basic approach an optimized version is described.

The emission/absorption model for participating media basically states that at each point in a volume a certain amount of light is emitted (this can also include in-scattering) and and absorbed (this can include out-scattering). This article is focused on a practical implementation of the model, so I won't go into the theory. The model is derived and described in more detail in [1].

If the problem is discretized we get the familiar front-to-back compositing algorithm for each viewing ray:

I = 0.0; T = 1.0; i = n; while( T > epsilon && i >= 1 ) { I = I + T*g[i]; T = T*t[i]; --i; } I = I + T*I0; Here, n is the number of samples to be taken, I is the accumulated intensity (color), T is the accumulated transmittance, g[i] is the source term of the i-th ray segment, t[i] its transmittance, and I0 is the intensity that enters the volume (the background color). If no early-ray termination (T £ e) is required (e.g. because it is extremely unlikely for the transmittance to drop below e), the algorithm above can more conveniently be written as a for-loop that accumulates a fixed number of samples:

I = 0.0; T = 1.0; for( int i=0; i