2D GLSL Pixelated Retro Filter

Hi, im making some Dungeon Master type game in UPBGE 0.3 EEVEE (Dont ask why) and i want to make some pixelated filter. These old filters i found dont work on this version. Can anybody write me this filtere please or rewrite this old one?

uniform float bgl_RenderedTextureWidth;
uniform float bgl_RenderedTextureHeight;

uniform sampler2D bgl_RenderedTexture;

float width = bgl_RenderedTextureWidth;
float height = bgl_RenderedTextureHeight;

float wsize = 2.0;
float hsize = 2.0;

void main(void)
{
	vec2 Tile = vec2(wsize/width,hsize/height);
	vec2 Blur = vec2(0.0,0.0);

	vec2 texCoord = gl_TexCoord[0].xy;
	vec2 tilePos = vec2(fract(texCoord.x / Tile.x), fract(texCoord.y / Tile.y));
	
	// Bottom-left of current tile
	vec2 p0 = vec2(floor(texCoord.x / Tile.x) * Tile.x, floor(texCoord.y / Tile.y) * Tile.y);
	// Bottom-left of tile to Left of current tile
	vec2 p1 = vec2(clamp(p0.x - Tile.x, 0.0, 1.0), p0.y);
	// Bottom-left of tile Below current tile
	vec2 p2 = vec2(p0.x, clamp(p0.y - Tile.y, 0.0, 1.0));
	// Bottom-left of tile Below and Left of current tile
	vec2 p3 = vec2(p1.x, p2.y);

	vec2 mixFactors;
	mixFactors.x =  min(tilePos.x / Blur.x, 1.0);
	mixFactors.y =  min(tilePos.y / Blur.y, 1.0);

	vec4 tmp1 = mix(texture2D(bgl_RenderedTexture, p1+(Tile/2.0)), texture2D(bgl_RenderedTexture, p0+(Tile/2.0)), mixFactors.x);
	vec4 tmp2 = mix(texture2D(bgl_RenderedTexture, p3 +(Tile/2.0)), texture2D(bgl_RenderedTexture, p2+(Tile/2.0)), mixFactors.x);
	gl_FragColor = mix(tmp2, tmp1, mixFactors.y);

}
2 Likes

have to declare in/out s

3 Likes

thank you sir!

glad to be of help.