Liam White
Extending FidelityFX FSR to support an alpha channel

Note: this post only deals with FSR 1.0, but the technique is applicable to any resampling filter.

While FSR's RCAS pass can support an alpha channel, the EASU pass cannot. The easiest way to deal with this is to simply pass through the alpha using the bilinear sampler from the source texture when writing the EASU output.

Code is adapted from here.

layout (binding = 0, set = 0) uniform sampler2D inputTexture;
layout (location = 0) in vec2 fragTexcoord;
layout (location = 0) out vec4 fragColor;
layout (push_constant) uniform constants {
    uvec4 const0;
    uvec4 const1;
    uvec4 const2;
    uvec4 const3;
};

// ... definitions omitted ...

#define FSR_RCAS_PASSTHROUGH_ALPHA 1
#include "ffx_a.h"

void Easu(AU2 pos) {
    AU2 pos = AU2(gl_FragCoord.xy);
    AF3 c;
    FsrEasuF(c, pos, const0, const1, const2, const3);
    fragColor = AF4(c, texture(inputTexture, fragTexcoord).a);
}

void Rcas(AU2 pos) {
    AU2 pos = AU2(fragTexcoord * vec2(textureSize(inputTexture, 0)));
    AF4 c;
    FsrRcasF(c.r, c.g, c.b, c.a, pos, const0);
    fragColor = c;
}

Some other options for if you are feeling especially fancy:

  1. Implement Lanczos resampling instead of basic bilinear filtering
  2. Render to a second image where each pixel value is (a, a, a, 1.0) and filter it using EASU, then sample it in the RCAS pass