Pixelate shader/filter for UPBGE - how to make edges of objects not blurry

I’ve been having some trouble with using this pixel shader for my game. The edges of objects aren’t sharp or crisp, like when I play and record my game at 240p (with no shader), vs recording it at 960p with the shader applied. Recording it at a lower resolution yields the correct result of what I’m trying to achieve. Is there a way to mitigate the blurriness of the outlines of objects at higher resolutions with the shader applied?

The problem:
image

What is the resolution when you go full screen? Maybe it needs to be dividable by 4 in the script?

That doesn’t work. Is there a way to get a sharper effect regardless of screen size?

set the AA(anti alias) higher

Tried that via the properties panel, but setting it higher does the opposite of what I need, I need it completely off to get the pixelation effect.

320x240 to 1280x960

I have no idea how to code glsl shader but I did google for an hour just because I wanted to know if this is possible to fix. It seems it should be in an interpolation mode but I have no idea how to add it to the shader.

GL_NEAREST is needed to add.
https://www2.cs.sfu.ca/~haoz/teaching/htmlman/texparameter.html

1 Like

Ah, thank you! I cam across this as well and have reached the same wall as how to use this since I barely know how GLSL works as well.

The only other method I could find was someone recommended was to use RenderToTexture, and I tried to do that but there doesn’t seem to be a way to force blender (in this mode) to render without AA, and it seems like it’s tied to the window size. I looked through the API and the “scale” function is supposed to implement nearest neighbor scaling for video textures, but I am not sure how to implement it.

Also here’s an example of how using RenderToTexture does lowers the resolution, but it’s still blurry
.
image

I’ve been considering even making some sort of wrapper as an extension of the game exe itself to just resize the game that way and circumvent this problem, but I have no idea how to do that either.

here’s another closeup of the thing where there is a slight transparency that happens along the edges that has been driving me nuts.
image

So far the best way I can think of fixing this is by altering the pixelate filter in the OP to make the edges not blurry but I can’t figure it out.

Add this script in the code to get rid of all mipmapping

from bge import render
render.setMipmapping(render.RAS_MIPMAP_NONE)

It seems to fix the problem.

This works for all textures in the image except for the video (Render-to-texture) texture
image

Could you share me that file so I can have a look?

r2t_attempt_09.blend (834.7 KB)

Sure (I was using UPBGE)

I got nothing. Sorry. :confused: Tried the mipmap false thingy and it does nothing.

1 Like

Same here, thank you for your help so far though! I will update here if I find a solution

1 Like