Per-Pixel Linked Lists
A way to implement Transparency on a Graphics Pipeline .
Overview #
- Don’t render into a color-render target. (Discard the fragment)
- Write fragments in FS into a huge separate buffer to store all rendered fragments
- At the end: Build a linked list structure of fragments that fall into the same pixel
- After that render a full-screen quad -> FS does the alpha blending using the linked lists
Used data structures #
-
Start Offset Buffer:
- same size as viewport
- initializes to -1
- stores the index into the fragment in the Fragment and Link Buffer that was rendered last for every pixe
-
Fragment and Link Buffer:
- Stores the output of all fragment shaders
- Stores an “next” index per entry
-
Counter
- atomic integer that counts how many fragments are in Fragment and Link Buffer
Process of handling fragments #
- Write the fresh fragment into the next free slot (reading the atomic counter an incrementing it) in the Fragment and Link Buffer
- Set it’s “next” index to the one, that is stored in the Start Offset Buffer
- Overwrite the index in Start Offset Buffer with the counter (that was incremented in 1)
- Discard the fragement in the FS so it does not go through the Output Merger (all necessary information is in the Fragment and Link Buffer)
Second render pass #
- With the two buffers from the first render pass, render a full screen quad (2 tris) and in the FS handle the color blending.
- If this fragment has still -1 in the Start Offset Buffer, discard it (as in the first render pass, it was also not hit)
- Else: first sort the fragments from the linked list that correspond to the current fragment, then do the alpha blending
Evaluation #
Con:
- The Fragment and Link Buffer must be large enough to store all rendered fragments. It can become huge.