I just made this pixelate filter, it doesn’t produce the anti-aliasing effect of SL_RU’s filter.
For UPBGE 0.3, uncomment the 5th line: remove the double slash (//) only. Also, set the sampling to 1.
// Pixelate 2D Filter by MattFrnndz
// It produces sharp edges, without anti-aliasing effect
// on UPBGE 0.3, uncomment the following line (remove //)
//#define UPBGE3
int pixelSize = 4;
uniform sampler2D bgl_RenderedTexture;
uniform float bgl_RenderedTextureWidth;
uniform float bgl_RenderedTextureHeight;
#ifndef UPBGE3
vec2 texCoord = gl_TexCoord[0].st;
#else
in vec4 bgl_TexCoord;
vec2 texCoord = bgl_TexCoord.xy;
out vec4 fragColor;
#define gl_FragColor fragColor
#endif
void main(void)
{
float pS = float(pixelSize);
vec2 pixelRes = vec2(bgl_RenderedTextureWidth / pS,
bgl_RenderedTextureHeight / pS);
float offset = 1.5 / pS;
vec2 pixCoords = vec2((floor(texCoord.x * pixelRes.x) + offset) / pixelRes.x,
(floor(texCoord.y * pixelRes.y) + offset) / pixelRes.y);
gl_FragColor = texture2D(bgl_RenderedTexture, pixCoords);
}
