Very Simple Letterbox Shader
A simple shader that replicates a letterbox effect.
Shader code
/* Simple Godot Letterbox Shader - Kanjo (CC0) */
shader_type canvas_item;
uniform float squishedness = 0.0;
void fragment() {
if (SCREEN_UV.y < squishedness * 0.5 || SCREEN_UV.y > 1.0 - (squishedness * 0.5)) COLOR = vec4(0, 0, 0, 1);
}
/* Better solution (credit to Beebe Ray in comments) */
shader_type canvas_item;
uniform float squishedness = 0.0;
void fragment() {
COLOR = mix(
vec4(vec3(0.0), 1.0),
texture(SCREEN_TEXTURE, SCREEN_UV),
step(squishedness * 0.5, SCREEN_UV.y) - step(1.0 - squishedness * 0.5, SCREEN_UV.y)
);
}
One line instead.
ah yes, the classic commenter does better xd