
122 II Lighting
Figure 4.34. A light ray march for each view ray-march step.
cloud_test = SampleCloudDensity ( p , weather_data ,
mip_level , true );
if( cloud_test == 0.0)
{
p += step ;
}
}
}
This algorithm cuts the number of 3D texture calls in half for the best case,
where we are marching through empty sky.
To calculate the lighting, more samples need to be taken toward the light at
each ray-march step. The sum of these samples is used in the lighting model and
then attenuated by the current sum of density along the view ray for each view
ray-march step. Figure 4.34 illustrates a basic light sample integration march
within a ray march.
Because we are ta