FXAA filter removes transparency


I noticed using FXAA filter in my icon generator causes the generated PNG to have no transparency.

Diving into shader code I noticed here in the fragment shader

it sets gl_FragColor alpha to 1.0, is this done intentionally?

or it should change to this:

vec4 texVal = texture2D(m_Texture, texCoord);
gl_FragColor = vec4(FxaaPixelShader(posPos, m_Texture, g_ResolutionInverse), texVal.a);

Note, not a problem for me as I am using regular AA sampling, I just wanted to know if this needs to be fixed in the shader.

Your change looks good but I don’t know the inner workings and passes of the FXAA filter and if this change could harm the effect result. I’ll have a look at it later today and give you more feedback :wink:


Just checked the filter code, and it’s just a simple pass one. I’ve not tested it but setting proper alpha shouldn’t change the rendering result in this case.

I had a similar issue using SSAO wiht the screen capture thing you help me with here

When adding the filter the background went black and I had to add the following code

if(texture2D(m_Normals, texCoord).a < 0.1)

at the beginning of ssao.frag main: jmonkeyengine/ssao.frag at 98f6d326e1d062aa4e1103e4729c02f0c0f16cc1 · jMonkeyEngine/jmonkeyengine · GitHub

I’m using the exact same shader for regular SSAO filtering on the rendered viewport without issues

1 Like

Thanks for the feedback. Will submit the patch soon.