Graphics Reference
In-Depth Information
2.3.7 Saving the Right Pixel Depth for Lookup
Once the per-pixel linked list is sorted based on depth, the algorithm needs to
assess what is the correct pixel to be rendered on screen for each pixel in the
list. We begin traversing the linked list from the closest pixel to the farthest
one. If any front-facing pixel of M+ is found that is currently outside of M
,
then that is the pixel to be rendered on screen. If any back-facing pixel of M
is found that is currently inside of M+, then that is the pixel to be rendered on
screen. If there is a valid M+ and M
pixel to be rendered, whichever is closest
to the camera wins. The front-facing M+ or back-facing M
pixel to render will
be referred to in this chapter as the eligible rendered pixel for consistency. If
we used the per-pixel linked lists exemplified in Figure 2.1 to retrieve the set of
eligible rendered pixels, we would have none for the green line of sight, the first
M
back-facing pixel for the red line of sight, and the first M+ front-facing pixel
for the blue line of sight.
The eligible rendered pixel case described above works when M+ is a non-flat
mesh (such as a cube). When M+ is a flat mesh (such as a wall), then the eligible
rendered pixel is either any front-facing pixel of M+ that is outside of M
,or
the first back-facing pixel of M
that lies behind a M+ front-facing pixel.
Via this heuristic, the method to communicate to the final render pass (the
next step in the algorithm) the eligible rendered pixel, is by storing the eligible
rendered pixel depth value in an auxiliary texture buffer. The final pass rendering
step will then use that auxiliary texture buffer as a lookup table. Please see the
book's website for the code that executes all of the steps outlined in this section.
2.3.8 Final Pass Render
In the final render pass, we re-render the front-facing pixels of M+, as well as
the back-facing pixels of M
, with a final pass shader. This final pass shader
will compare the incoming fragment's depth value with what is stored in the
auxiliary texture buffer. If the fragment's depth value is equal to the one stored
in the auxiliary texture buffer, then that means that the incoming fragment
is the eligible rendered pixel. It then gets rendered in the render target. All
other fragments are clipped. Figure 2.2 displays how Figure 2.1 would look after
M+
Camera
Figure 2.2. The final scene once M is subtracted from M+.
Search WWH ::




Custom Search