I have the following situation. I work on OpenGL renderer (OpenGL 4.2 so no fixed stuff).I DON"T use hardware blending for the reasons related to all sort of image effects I do in shaders.I have as my input textures of 2 types:
1) PNG 24 with alpha channel. 2)DDS (DXT5) with alpha channel.
In the fragment shader I pre-muliply alpha before output:
Fragment shader:
outputColor=texture(colorMap,interpolateAtSample(uvsOut , gl_SampleID));
/////// PREMULTIPLY ALPHA //////////
outputColor.a *= alpha;
outputColor.rgb *= outputColor.a;
PNG based textures work fine:
But DDS looks like this:
You can see the halo + black edge. First thing I thought was the problem with alpha multiplication.But then I changed Texture filtering for DDS from GL_LINEAR to GL_NEAREST and it removed both the halo and black edge. While this "hack" essentially fixed the problem I still would like to understand why GL_LINEAR causes this sort of issues to DDS compressed textures.
Almost forgot: If I remove pre - multiplication it solves the issue for DDS but creates one for PNG based textures.
UPDATE: There is another pass which comes after the MSAA resolve and that is blend pass.As I mentioned , I don't do any blend in this case but the output code in the blend shader looks like this:
///Prevent background bleeding:
blendTex.rgb/=blendTex.a;
//base texture is the texture under the current one.
//This particular technique does "NORMAL" blend-just returns blendTex.
vec4 blendedRes=blendTechnique( baseTex , blendTex) ;
outputColor= vec4( blendedRes.rgb * blendTex.a, blendTex.a);