Graphics Reference
In-Depth Information
// Get the new c e l l number as well .
const float2 newCellIdx = getCell ( tmpRay . xy , cellCount );
// If the new cell number is different from the old cell
// number , we know we crossed a c e l l .
[ branch ]
if ( crossedCellBoundary ( oldCellIdx , newCellIdx ))
{
// So intersect the boundary of that cel l instead ,
// and go up a level for taking a larger step next
// loop .
tmpRay = intersectCellBoundary ( o , d , oldCellIdx ,
cellCount . xy , crossStep . xy , crossOffset . xy );
level = min ( HIZ_MAX_LEVEL , level +2.0 f );
}
ray . xyz = tmpRay . xyz ;
// Go down a leve l
in the Hi Z.
−− level ;
++ iterations ;
}
// end while
return ray ;
}
Listing 4.5. Some of the functions are not shown because of code length. This is only a
minimum tracing for the sake of simplicity. The full implementation of those functions
can be seen with the demo code on the topic's website. The demo uses minimum-
maximum tracing, which is a bit more complicated than this. View-space Z tracing is
a bit more complicated and not shown.
4.5.4 Pre-convolution Pass
The pre-convolution pass is just a simple separable blur with normalized weights
so that they add up to 1.0 when summed—otherwise we would be creating more
energy than what we had to begin with in the image. (See Figure 4.22.)
The filter is executed successively on the color image and at each step we
reduce the image to half the size and store it in the mip-channels of the texture.
Assuming that we are at half resolution, this would correspond to 960
×
540;
when convolving level 2 (240
×
135), we read from level 1 (480
×
270) and apply
the separable blur passes.
The 1D Gaussian function for calculating our horizontal and vertical blur
weights is
1
2 πσ 2 e x 2
G ( x )=
2 σ 2 .
So, for example, a 7
×
7 filter would have an inclusive range from
3to3for x .
Search WWH ::




Custom Search