Graphics Reference
In-Depth Information
the overestimating conservative bounding triangle in the geometry shader and is
passed to the pixel shader as well. Note that modifying the triangle may change
its depth derivatives, unless the resulting triangle is realigned with the plane of
the original triangle.
To be able to reconstruct the proper grid space coordinates of a rasterized
triangle, we also need to pass the chosen direction of projection to the pixel shader.
This only requires two bits, so we reuse the storage of the four
srequiredto
pass the clipping AABB to the pixel shader. As all fragment coordinates in screen
space are nonnegative, we encode the three possible directions in the unused sign
bits of two of the AABB components.
float
Conservative depth bounds estimation. During rasterization, a pixel shader is exe-
cuted for each voxel column covered by the projected triangle. To conservatively
find which voxels are intersected, we need to compute a depth range spanning
from the closest to the farthest point on the projected triangle inside each voxel
column. We can then iterate over all (fully or partially) overlapping voxels in the
pixel shader.
To compute this depth range we use the pixel shader gradient instructions
provided by HLSL. The intrinsic function fwidth returns the sum of the absolute
partial derivatives for a given variable. The derivatives are evaluated at the
location for which the pixel shader was executed, scaled to pixel steps. Since
our projection is orthographic and thus our depth values are linear, this sum
coincides with the maximum depth delta of the triangle inside a fully covered
voxel column. As rasterization yields depth values interpolated at pixel centers
(green in Figure 2.6), we add and subtract one half of the depth derivative to
obtain a conservative estimate for the depth range that contains all potentially
touched voxels.
2.4.2 Ray Grid Construction
We do classic ray marching in a compute shader to fill the ray grid with ray links.
We transform both origin and direction of each ray into the grid and then work
our way through the ray grid cell by cell.
For every cell crossed by a given ray, we first check if that cell is actually
occupied by any scene geometry. In our implementation, the ray grid and the
grid of the voxel representation always align, therefore this information can be
retrieved using a single texture lookup in the voxel representation. For occupied
cells, the ray is queued into the respective ray grid cell, to be tested against the
actual triangle geometry overlapping that cell in the subsequent precise inter-
section testing stage. For empty cells, no further action is taken and marching
simply continues to the next cell.
Note that filling the ray grid requires a conservative ray marching that does
not skip cells in passing. Hence, it would not be sucient to use a fixed step size,
Search WWH ::




Custom Search