#Pixelate Shader

7 messages · Page 1 of 1 (latest)

patent vortex
#

I followed a tutorial to create a shader in 3d, but i've tried to convert it to 2d so it fits with the rest of my shaders.
Instead of pixelating the image, its instead drawing these grid lines and i'm not sure why.
Any help fixing this would be appreciated.

Heres the shader.

shader_type canvas_item;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

const int pixel_size = 25;

void fragment() {
float x = float(int(FRAGCOORD.x) % pixel_size);
float y = float(int(FRAGCOORD.y) % pixel_size);

x = FRAGCOORD.x + floor(float(pixel_size) / 2.0) - x;
y = FRAGCOORD.y + floor(float(pixel_size) / 2.0) - y;

vec3 tex_color = texture(SCREEN_TEXTURE, vec2(x, y)).xyz;
COLOR = vec4(tex_color, 1); 

}

fleet steeple
#

Is your entire game 3d pixelated ? or this is just an temporary effect ?

#

Here's a simple 3d pixelated effect:

shader_type spatial;
render_mode unshaded;
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

const int pixel_size = 200;

void fragment() {
    vec2 uv = floor(SCREEN_UV.xy * float(pixel_size)) / float(pixel_size);
    ALBEDO = texture(SCREEN_TEXTURE, uv).rgb;
}
#

You apply this shader on a mesh object and look through it, like "glass"

patent vortex
#

the game itself is 3d but i wanted to convert the shader to 2d so it can be stored with my other shaders in hierarchy. This looks like what i started with kekw_dog

fleet steeple
#

i would suggest if the entire game is going to use this technique, consider using a viewport, so you actually render at small resolution and avoid rendering unused pixels

#

you want a shader that applies on a canvasitem and pixelize the screen information of a 2d scene ? not a 3d scene