How can I get a 2D Filter to show the game view rather than being a solid colour?

uniform sampler2D bgl_RenderedTexture;
in vec4 bgl_TexCoord;
out vec4 fragColor;
void main(void) {
    vec4 texcolor = texture(bgl_RenderedTexture, bgl_TexCoord.xy);
    float gray = dot(texcolor.rgb, vec3(1,1,1));
    fragColor = vec4(gray * vec3(1,0,0), texcolor.a);
}

UPBGE 0.3 Sepia Shader: https://github.com/UPBGE/upbge/blob/master/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.glsl
Old, but good explanation: https://sites.google.com/site/blendergameengine/customfilter

Use bge.types.BL_Shader.setSource instead. Although, I’m not sure if UPBGE 0.3+ still supports this method (it might be different). EDIT: Apparently it’s no longer supported. See here.

Documentation: https://upbge.org/#/documentation/docs/latest/api/bge.types.BL_Shader.html#bge.types.BL_Shader.setSource
Example: https://github.com/mikepan/GameEngineBook/blob/master/text/05-Graphics.md#custom-glsl-shaders--1