quakeforge/libs/video/renderer/vulkan/shader/oit_store.finc
Bill Currie 00cade072c [vulkan] Implement order implement transparency
It's a bit flaky for particles, especially at higher frame rates, but
that's due to supporting only 64 overlapping pixels. A reasonable
solution is probably switching to a priority heap for the "sort" and
upping the limit.
2022-12-01 03:00:47 +09:00

14 lines
364 B
Text

#include "oit.h"
void
StoreFrag (vec4 color, float depth)
{
int index = atomicAdd (numFragments, 1);
ivec2 coord = ivec2(gl_FragCoord.xy);
if (index < maxFragments) {
int prevIndex = imageAtomicExchange (heads, coord, index);
fragments[index].color = color;
fragments[index].depth = depth;
fragments[index].next = prevIndex;
}
}