godot-xterm/addons/SIsilicon.3d.text/text_viewport.tscn

75 lines
1.7 KiB
Text
Raw Normal View History

[gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/SIsilicon.3d.text/default_font.ttf" type="DynamicFontData" id=1]
[sub_resource type="Environment" id=1]
background_mode = 1
background_energy = 0.0
[sub_resource type="World" id=2]
environment = SubResource( 1 )
[sub_resource type="DynamicFont" id=3]
size = 100
font_data = ExtResource( 1 )
[sub_resource type="Shader" id=4]
code = "shader_type canvas_item;
uniform int Max = 3;
float getAlpha(sampler2D tex, ivec2 coord) {
return texelFetch(tex, coord, 0).r;
}
void fragment() {
ivec2 coord = ivec2(FRAGCOORD.xy);
bool inside = getAlpha(SCREEN_TEXTURE, coord) > 0.5;
float dist = float((Max+1) * (Max+1));
for(int y = -Max; y <= Max; y++) {
for(int x = -Max; x <= Max; x++) {
if(x == 0 && y == 0) continue;
ivec2 delta = ivec2(x,y);
if(inside) {
if(getAlpha(SCREEN_TEXTURE, coord + delta) < 0.5) {
dist = min(dist, float(x*x + y*y));
}
} else {
if(getAlpha(SCREEN_TEXTURE, coord + delta) > 0.5) {
dist = min(dist, float(x*x + y*y));
}
}
}
}
dist = sqrt(dist) * (float(!inside) * 2.0 - 1.0);
COLOR = vec4(dist / float(Max+1));
}"
[sub_resource type="ShaderMaterial" id=5]
shader = SubResource( 4 )
shader_param/Max = 10
[node name="Viewport" type="Viewport"]
size = Vector2( 190, 114 )
own_world = true
world = SubResource( 2 )
transparent_bg = true
handle_input_locally = false
render_target_update_mode = 1
gui_disable_input = true
[node name="Label" type="Label" parent="."]
margin_right = 190.0
margin_bottom = 114.0
size_flags_horizontal = 4
custom_fonts/font = SubResource( 3 )
text = "Text"
[node name="ColorRect" type="ColorRect" parent="Label"]
material = SubResource( 5 )
anchor_right = 1.0
anchor_bottom = 1.0