Skip to content

Instantly share code, notes, and snippets.

@partybusiness
Last active August 7, 2025 03:07
Show Gist options
  • Save partybusiness/35efbab03ff1cbbe7eaa04a1a88a06d4 to your computer and use it in GitHub Desktop.
Save partybusiness/35efbab03ff1cbbe7eaa04a1a88a06d4 to your computer and use it in GitHub Desktop.
fake perspective shader in Godot
shader_type canvas_item;
uniform sampler2D main_texture:source_color, repeat_disable;
uniform float scale_x_bottom = 1.0;
uniform float scale_x_top = 1.0;
void fragment() {
vec2 uv = (UV - vec2(0.5, 0.5)) * mix(scale_x_top, scale_x_bottom, UV.y) + vec2(0.5, 0.5);
COLOR = texture(main_texture, uv);
if (uv.x < 0.0 || uv.x > 1.0 || uv.y > 1.0 || uv.y < 0.0)
COLOR.a = 0.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment