2017-10-20 22:00:56 -05:00
|
|
|
#version 150
|
|
|
|
|
|
2023-12-08 13:02:43 +01:00
|
|
|
// clang-format off
|
2017-10-20 22:00:56 -05:00
|
|
|
uniform usampler2D uOpaqueTex;
|
|
|
|
|
uniform sampler2D uOpaqueDepth;
|
|
|
|
|
uniform usampler2D uTransparentTex;
|
|
|
|
|
uniform sampler2D uTransparentDepth;
|
2020-09-04 14:08:59 +02:00
|
|
|
uniform usampler2D uPaletteTex;
|
2023-12-03 18:58:28 +01:00
|
|
|
uniform usampler2D uBlendPaletteTex;
|
2023-12-09 19:42:41 +01:00
|
|
|
// clang-format on
|
2017-10-20 22:00:56 -05:00
|
|
|
|
|
|
|
|
in vec2 fTextureCoordinate;
|
|
|
|
|
|
|
|
|
|
out uint oColour;
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
|
{
|
2023-12-09 19:42:41 +01:00
|
|
|
uint opaque = texture(uOpaqueTex, fTextureCoordinate).r;
|
2017-10-20 22:00:56 -05:00
|
|
|
float opaqueDepth = texture(uOpaqueDepth, fTextureCoordinate).r;
|
2023-12-09 19:42:41 +01:00
|
|
|
uint transparent = texture(uTransparentTex, fTextureCoordinate).r;
|
2017-10-20 22:00:56 -05:00
|
|
|
float transparentDepth = texture(uTransparentDepth, fTextureCoordinate).r;
|
|
|
|
|
|
2017-10-21 21:04:24 -05:00
|
|
|
if (opaqueDepth <= transparentDepth)
|
2017-10-20 22:00:56 -05:00
|
|
|
{
|
|
|
|
|
transparent = 0u;
|
|
|
|
|
}
|
2023-12-09 19:42:41 +01:00
|
|
|
|
2023-12-03 18:58:28 +01:00
|
|
|
uint blendColour = (transparent & 0xff00u) >> 8;
|
2023-12-09 19:42:41 +01:00
|
|
|
if (blendColour > 0u)
|
2023-12-03 18:58:28 +01:00
|
|
|
{
|
2023-12-09 19:42:41 +01:00
|
|
|
if ((transparent & 0x00ffu) != 0u)
|
2023-12-03 18:58:28 +01:00
|
|
|
{
|
|
|
|
|
oColour = blendColour;
|
|
|
|
|
}
|
2023-12-09 19:42:41 +01:00
|
|
|
else
|
2023-12-03 18:58:28 +01:00
|
|
|
{
|
|
|
|
|
oColour = texture(uBlendPaletteTex, vec2(opaque, blendColour) / 256.f).r;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
oColour = texture(uPaletteTex, vec2(opaque, transparent) / 256.f).r;
|
|
|
|
|
}
|
2017-10-20 22:00:56 -05:00
|
|
|
}
|