Created
December 24, 2024 11:09
-
-
Save Shilo/46711a5807e9b28cac2a2029665cd299 to your computer and use it in GitHub Desktop.
Godot 4 simple canvas item shader to add inner border.
This file contains 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; | |
uniform vec4 border_color: source_color = vec4(1.0); | |
uniform float border_width: hint_range(0, 10) = 0; | |
void fragment() { | |
float border_width_uv = border_width * max(TEXTURE_PIXEL_SIZE.x, TEXTURE_PIXEL_SIZE.y); | |
if (step(0.5 - border_width_uv, abs(UV.x - 0.5)) == 1.0 || | |
step(0.5 - border_width_uv, abs(UV.y - 0.5)) == 1.0) { | |
COLOR = border_color; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment