Skip to content

Commit

Permalink
add border to title screen logo
Browse files Browse the repository at this point in the history
  • Loading branch information
singerbj committed Apr 27, 2024
1 parent 46e9550 commit e97dccd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scenes/TitleScreen.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://42qq4ke7te0s"]
[gd_scene load_steps=8 format=3 uid="uid://42qq4ke7te0s"]

[ext_resource type="Theme" uid="uid://cw2jrsfudbjvg" path="res://default_theme.tres" id="1_clfqb"]
[ext_resource type="Texture2D" uid="uid://c3wki3kjoisgc" path="res://assets/art/logo_transparent.PNG" id="2_3quqd"]
[ext_resource type="Shader" path="res://shaders/logo.gdshader" id="2_ohgnl"]

[sub_resource type="Theme" id="Theme_1ea38"]
default_font_size = 50
Expand All @@ -12,6 +13,11 @@ default_font_size = 50
[sub_resource type="Theme" id="Theme_py6c5"]
default_font_size = 50

[sub_resource type="ShaderMaterial" id="ShaderMaterial_nh4jm"]
shader = ExtResource("2_ohgnl")
shader_parameter/line_color = Color(0, 0, 0, 1)
shader_parameter/line_thickness = 10.0

[node name="TitleScreen" type="Panel"]
offset_left = -2.0
offset_top = -2.0
Expand Down Expand Up @@ -68,6 +74,7 @@ theme = SubResource("Theme_py6c5")
text = "Fullscreen"

[node name="Logo" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_nh4jm")
position = Vector2(1500, 548)
scale = Vector2(0.889648, 0.889648)
texture = ExtResource("2_3quqd")
22 changes: 22 additions & 0 deletions shaders/logo.gdshader
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
shader_type canvas_item;

uniform vec4 line_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float line_thickness : hint_range(0, 10) = 1.0;

const vec2 OFFSETS[8] = {
vec2(-1, -1), vec2(-1, 0), vec2(-1, 1), vec2(0, -1), vec2(0, 1),
vec2(1, -1), vec2(1, 0), vec2(1, 1)
};

void fragment() {
vec2 size = TEXTURE_PIXEL_SIZE * line_thickness;
float outline = 0.0;

for (int i = 0; i < OFFSETS.length(); i++) {
outline += texture(TEXTURE, UV + size * OFFSETS[i]).a;
}
outline = min(outline, 1.0);

vec4 color = texture(TEXTURE, UV);
COLOR = mix(color, line_color, outline - color.a);
}

0 comments on commit e97dccd

Please sign in to comment.