Commit 712e58da authored by Christopher Tenter's avatar Christopher Tenter

fix artifacts at pixels where too many layers overlap (OITLinkedList)

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free-Staging@20191 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8081530b
......@@ -40,10 +40,10 @@ void main()
// keep track of list size
int listSize = 0;
vec4 dbgColor = vec4(1,1,1,1);
vec4 dbgColor = vec4(1, 1, 1, 1);
// read linked list from ABuffer, starting at offset of list head
while (uiOffset != 0xffffffff && listSize < MAXLISTSIZE)
while (uiOffset != 0xffffffff)
{
uvec4 fragEntry = imageLoad(g_ABuffer, int(uiOffset));
// fragEntry : (color, depth, next, coverage)
......@@ -54,16 +54,24 @@ void main()
#endif
{
list[listSize].color = fragEntry.x;
list[listSize].depth = uintBitsToFloat(fragEntry.y);
float fragDepth = uintBitsToFloat(fragEntry.y);
if (listSize < MAXLISTSIZE || list[listSize - 1].depth > fragDepth)
{
int insertPos = min(listSize, MAXLISTSIZE - 1);
list[insertPos].color = fragEntry.x;
list[insertPos].depth = fragDepth;
// insertion sort
int j = listSize;
int prev = max(j-1, 0);
int j = insertPos;
int prev = max(j - 1, 0);
// insertion sort: front to back
while( (j > 0) && (list[prev].depth > list[j].depth) )
while ((j > 0) && (list[prev].depth > list[j].depth))
{
// swap
FragListEntry tmp = list[j];
......@@ -71,10 +79,13 @@ void main()
list[prev] = tmp;
--j;
prev = max(j-1, 0);
prev = max(j - 1, 0);
}
listSize = min(listSize+1, MAXLISTSIZE);
listSize = min(listSize + 1, MAXLISTSIZE);
}
}
......@@ -82,11 +93,11 @@ void main()
uiOffset = fragEntry.z;
}
vec4 color = vec4(0,0,0,1);
vec4 color = vec4(0, 0, 0, 1);
// blend back to front
for (int i = listSize-1; i >= 0; --i)
for (int i = listSize - 1; i >= 0; --i)
{
vec4 fragColor = unpackUnorm4x8(list[i].color);
......@@ -94,10 +105,4 @@ void main()
}
outColor = color; // * gl_NumSamples;
// weird bug, for some reason color != (0,0,0,1) for unshaded pixels
if (startOffset == 0xffffffff)
outColor = vec4(0,0,0,1);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment