Move premultiplied alpha to shader

This commit is contained in:
Benau 2021-03-07 15:41:00 +08:00
parent db98783f09
commit 1d65cd9ffc
2 changed files with 3 additions and 20 deletions

View File

@ -11,6 +11,7 @@ out vec4 FragColor;
void main(void)
{
float billboard_alpha = mix(1.0, texture(tex, tc).a, billboard);
vec4 color = texture(tex, tc);
#if defined(Advanced_Lighting_Enabled)
vec2 xy = gl_FragCoord.xy / u_screen;
float FragZ = gl_FragCoord.z;
@ -21,5 +22,6 @@ void main(void)
#else
float alpha = 1.0;
#endif
FragColor = texture(tex, tc) * billboard_alpha * pc * alpha;
color = vec4(color.rgb * color.a, color.a);
FragColor = color * billboard_alpha * pc * alpha;
}

View File

@ -207,25 +207,6 @@ void STKTexture::formatConversion(uint8_t* data, unsigned int* format,
}
}
#endif
if (isPremulAlpha() && !m_single_channel)
{
for (unsigned int i = 0; i < w * h; i++)
{
float alpha = data[4 * i + 3];
if (alpha > 0.0f)
{
alpha /= 255.0f;
if (CVS->isDeferredEnabled())
{
alpha = pow(alpha, 1.0f / 2.2f);
}
}
data[i * 4] = (uint8_t)(data[i * 4] * alpha);
data[i * 4 + 1] = (uint8_t)(data[i * 4 + 1] * alpha);
data[i * 4 + 2] = (uint8_t)(data[i * 4 + 2] * alpha);
}
}
#endif // !SERVER_ONLY
} // formatConversion