Last active
January 9, 2026 03:51
-
-
Save partybusiness/35efbab03ff1cbbe7eaa04a1a88a06d4 to your computer and use it in GitHub Desktop.
fake perspective shader in Godot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| shader_type canvas_item; | |
| // displays a texture but distorts it based on the size of the top and bottom | |
| uniform sampler2D main_texture:source_color, repeat_disable; | |
| // scale the bottom of the image | |
| uniform float scale_x_bottom = 1.0; | |
| // scale the top of the image | |
| 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