Node Material Pixelation

Hello, I’m trying to create a pixelation effect in node material editor.
Someone knows how to get this done?
Should work more or less like this frag shader:

#ifdef GL_ES
        precision highp float;
    #endif

    uniform sampler2D textureSampler;
    uniform vec2 screenSize;
    uniform float pixelationLevel;
    void main()
    {
        vec2 pixelSize = vec2(1.0 / screenSize.x, 1.0 / screenSize.y);
        vec2 uv = gl_FragCoord.xy * pixelSize;
        uv = floor(uv / pixelationLevel) * pixelationLevel;
        gl_FragColor = texture2D(textureSampler, uv);
    }

Here the Lerp gives the final pixel color. I just don’t know how to combine these values to produce the pixelated look for the whole texture. Any ideas?
The result should actually pixelate the edges as well, not just the inner texture.

Here’s the editor url:

I think you want to apply the pixelation effect to the whole screen?

In this case, it is easier to create a post-processing node material:

Could do a post process but the problem is how to do gl_FragColor = texture2D(textureSampler, uv); in the material editor. I can’t achieve the pixelation result correctly in Node Material at all.

How about something like this:

1 Like