Can't Get UPBGE Custom 2d Filters to Work

Hey there! I’m fairly new to UPBGE and have been trying to get this pixel filter to work. I’m using the latest version of UPBGE and I’ve set up my logic like so:

with the “pixelate” script being the filter from the link above. My trouble is, when I start the game, the filter has no visible effect. I then tried using the custom blue sepia filter used as an example here to see if I could get a different filter to work. To my dismay, this yielded the same result, with no visible change being made in the scene.

I can provide any additional details, thank you for your time!

EDIT: I forgot to mention I tried the same setup in Blender 2.79 (without UPBGE) and the filter worked as expected.

It works for me:


pixelate.blend (656.8 KB)

There are just 2 changes:

gl_TexCoord[0] is replaced with bgl_TexCoord.xy (in vec4 bgl_TexCoord; declaration)
gl_FragColor is replaced with fragColor (out vec4 fragColor; declaration)

3 Likes

This worked flawlessly, thank you so much!

If anyone’s reading this and wants the finished code, it’s

//Author SL_RU. e-mail: [[email protected]](http://vk.com/[email protected])
//2013

uniform sampler2D bgl_RenderedTexture;

in vec4 bgl_TexCoord; //THIS IS NEW
out vec4 fragColor;   //THIS IS NEW

void main()
{float ScreenW = 640., ScreenH = 480.;
float Pixeliz = 5.;

float pixW = Pixeliz*(1./ScreenW), pixH = Pixeliz*(1./ScreenH);
vec2 pos = vec2(pixW*floor(bgl_TexCoord.x/pixW), pixH*floor(bgl_TexCoord.y/pixH));
fragColor = texture2D(bgl_RenderedTexture, pos);
}

Thank you again, you’re amazing!

1 Like

Hello,

i don’t know why but when i press P to play after putting the pixelate custom filter on, my UPBGE crashes :(. I tried to apply built-in filters and it makes this weird thing:


i also download the pixelate.blend file that is a few posts above and it crashes too, i tried built-in filters on it and it also makes the weird thing

if someone can help me,
thankssss

i dont know, i bet it has to do with your systems… graphics card OpenGl version supported.
have you tested upbge 2.5?

just to welcome you.

oh mac :expressionless: