Graphics Reference
In-Depth Information
Having the main scene depth buffer readily usable here allows for the use of
early depth stencil, so the depth comparison for hair fragments occurs before
pixel shader execution, effectively reducing the number of pixels that need to be
shaded and stored in the linked lists. In preparation for the Sort and Draw pass,
a stencil for the hair pixels is written. The Sort and Draw pass is a fullscreen
pass, so in order to make use of the early depth stencil again, a stencil comparison
must be used.
5.6.3 Sort and Draw
During the Sort and Draw pass, the per-pixel linked list (PPLL) generated by the
A-buffer Fill pass is traversed, sorted for the topmost hair pixels, then the final
blended hair pixel result is generated. This is a fullscreen pass, where each pixel
location is used to look up the corresponding per-pixel linked list. The topmost
fragments are found and stored locally. While searching for the topmost hair
fragments, the remaining hair fragments are blended out of order. The locally
stored topmost layers are then blended in order.
Finding the eight topmost fragments is sucient because of the contribution
of a fragment at layer eight and beyond start to get minimal, so the out of order
blending produces little to no variation in the final shaded result. The maximum
influence m of a hair fragment on the final shaded result can be calculated based
on the layer number n and the maximum alpha a possible for a hair fragment:
a ) nāˆ’ 1 .
m = a
āˆ—
(1
āˆ’
Given this formula, the maximum influence of a hair fragment at the eighth
layer is
0 . 01715, meaning the influence at layer eight is barely over one percent.
Layers beyond layer eight will influence the final shaded result less and less. Be-
cause of this, using the top eight layers is sucient enough to minimize variation
in the final shaded result.
The sorting is performed using the depth stored in the linked list node. To
search for the to most hair fragments, the linked list is simple iterated over, while
keeping a local copy of the current topmost hair fragments readily available for
a simple comparison.
ā‰ˆ
5.7 Integration Specifics
One thing not addressed in this chapter so far is writing depth for the hair in order
for hair to work correctly with depth-based effects, such as depth of field. We
cover three different ways to handle the depth write: writing a constant depth for
all hair pixels, precise depth per hair pixel, and a selective depth write with precise
depth per hair pixel. We chose to go with the last approach in Tomb Raider
because it was the solution that maximized quality and was tolerant enough to
Search WWH ::




Custom Search