pixelated horror vignette dot-matrix downres
this is a post-processing shader that can be attached to a quad in front of the camera like explained here in the docs. This should also be easy to convert to a canvasitem shader if going that route. I’ll do it if someone asks…
I use this in compatibility, so should work anywhere.
The settings used in the screenshot:
- Brightness: 0.26
- Contrast: 3
- Scale: 1
- Rotation: 0.08
- Resolution Downsampling: 4
Shader code
shader_type spatial;
render_mode unshaded, fog_disabled;
uniform vec3 luminance: source_color = vec3(0.3086, 0.6094, 0.0820);
uniform float brightness: hint_range(0.01, 20.0, .01) = 0.26;
uniform float contrast: hint_range(1.0, 4.0, .01) = 3.0;
uniform float scale: hint_range(0.1, 10.0, .01) = 1.0;
uniform float rotation: hint_range(0.00, 6.28, .01) = 0.08;
uniform float resolution_downsampling: hint_range(1.0, 8.0, 1.0) = 4.0;
uniform sampler2D screen_texture: hint_screen_texture, filter_nearest, repeat_disable;
mat2 rotate(float a) {
float sa = sin(a);
float ca = cos(a);
return mat2(vec2(ca, sa), vec2(-sa, ca));
}
void vertex(){
POSITION = vec4(VERTEX.xy, 1.0, 1.0);
}
float dot_matrix(vec2 uv) {
vec2 rot_uv = rotate(rotation) * uv * scale;
return sin(rot_uv.x) * sin(rot_uv.y);
}
void fragment() {
vec2 UV_new = SCREEN_UV - mod(SCREEN_UV, 1.0/VIEWPORT_SIZE * resolution_downsampling);
vec2 resolution = VIEWPORT_SIZE;
vec3 color = texture(screen_texture, UV_new).rgb;
float grey = dot(color, luminance) * contrast;
color = vec3(grey + dot_matrix(UV * resolution));
float vignette = smoothstep(0.45, 0.1, distance(UV, vec2(0.5))) * 1.0;
float v_x = smoothstep(0.45, 0.1, distance(UV.x, 0.5));
float v_y = smoothstep(0.45, 0.1, distance(UV.y, 0.5));
ALBEDO = vec3(color * brightness) * vignette;
}
Could you make it a canvas item shader?
Yes, here you are:
shader_type canvas_item; uniform vec3 luminance: source_color = vec3(0.3086, 0.6094, 0.0820); uniform float brightness: hint_range(0.01, 20.0, .01) = 0.26; uniform float contrast: hint_range(1.0, 4.0, .01) = 3.0; uniform float scale: hint_range(0.1, 10.0, .01) = 1.0; uniform float rotation: hint_range(0.00, 6.28, .01) = 0.08; uniform float resolution_downsampling: hint_range(1.0, 8.0, 1.0) = 4.0; uniform sampler2D screen_texture: hint_screen_texture, filter_nearest, repeat_disable; mat2 rotate(float a) { float sa = sin(a); float ca = cos(a); return mat2(vec2(ca, sa), vec2(-sa, ca)); } float dot_matrix(vec2 uv) { vec2 rot_uv = rotate(rotation) * uv * scale; return sin(rot_uv.x) * sin(rot_uv.y); } void fragment() { vec2 UV_new = SCREEN_UV - mod(SCREEN_UV, SCREEN_PIXEL_SIZE * resolution_downsampling); vec2 resolution = 1.0/SCREEN_PIXEL_SIZE; vec3 color = texture(screen_texture, UV_new).rgb; float grey = dot(color, luminance) * contrast; color = vec3(grey + dot_matrix(UV * resolution)); float vignette = smoothstep(0.45, 0.1, distance(UV, vec2(0.5))) * 1.0; float v_x = smoothstep(0.45, 0.1, distance(UV.x, 0.5)); float v_y = smoothstep(0.45, 0.1, distance(UV.y, 0.5)); COLOR = vec4((color * brightness) * vignette, 1.0); }dose it work with godot 4.3?
Flat-out doesn’t work. The canvas version posted in the comment does work, but isn’t transparent AKA you only see the dithering pattern and nothing underneath.
It worked for me. Just apply it to a sprite 2d texture as a child of the camera in the shape of the vignette you want.
Thank you for the canvas item shader too!
When used as a Quadmesh shader material, the quadmesh is a pure white. Is there a fix to this?