Browse Source

Add a 3D labels and texts demo

Hugo Locurcio 3 years ago
parent
commit
905717d462
28 changed files with 1230 additions and 0 deletions
  1. 78 0
      3d/labels_and_texts/3d_labels_and_texts.gd
  2. 692 0
      3d/labels_and_texts/3d_labels_and_texts.tscn
  3. 39 0
      3d/labels_and_texts/README.md
  4. 10 0
      3d/labels_and_texts/curvature.gdshader
  5. 7 0
      3d/labels_and_texts/default_env.tres
  6. BIN
      3d/labels_and_texts/fonts/Xolonium-Regular-MSDF-Mipmaps.ttf
  7. 33 0
      3d/labels_and_texts/fonts/Xolonium-Regular-MSDF-Mipmaps.ttf.import
  8. BIN
      3d/labels_and_texts/fonts/Xolonium-Regular-MSDF.ttf
  9. 33 0
      3d/labels_and_texts/fonts/Xolonium-Regular-MSDF.ttf.import
  10. BIN
      3d/labels_and_texts/fonts/Xolonium-Regular-Mipmaps.ttf
  11. 33 0
      3d/labels_and_texts/fonts/Xolonium-Regular-Mipmaps.ttf.import
  12. BIN
      3d/labels_and_texts/fonts/Xolonium-Regular.ttf
  13. 33 0
      3d/labels_and_texts/fonts/Xolonium-Regular.ttf.import
  14. 15 0
      3d/labels_and_texts/fonts/config.json
  15. BIN
      3d/labels_and_texts/fonts/fontello-godot.woff2
  16. 33 0
      3d/labels_and_texts/fonts/fontello-godot.woff2.import
  17. BIN
      3d/labels_and_texts/icon.png
  18. 36 0
      3d/labels_and_texts/icon.png.import
  19. 68 0
      3d/labels_and_texts/label_3d_layout.gd
  20. 36 0
      3d/labels_and_texts/project.godot
  21. 0 0
      3d/labels_and_texts/screenshots/.gdignore
  22. BIN
      3d/labels_and_texts/screenshots/3d_labels_and_texts.png
  23. 7 0
      3d/labels_and_texts/textures/checker.LICENSE.md
  24. BIN
      3d/labels_and_texts/textures/checker.png
  25. 36 0
      3d/labels_and_texts/textures/checker.png.import
  26. 7 0
      3d/labels_and_texts/textures/textmesh_texture.LICENSE.md
  27. BIN
      3d/labels_and_texts/textures/textmesh_texture.png
  28. 34 0
      3d/labels_and_texts/textures/textmesh_texture.png.import

+ 78 - 0
3d/labels_and_texts/3d_labels_and_texts.gd

@@ -0,0 +1,78 @@
+extends Node
+
+const ROT_SPEED = 0.003
+const ZOOM_SPEED = 0.125
+const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
+
+var tester_index = 0
+var rot_x = -TAU / 16  # This must be kept in sync with RotationX.
+var rot_y = TAU / 8  # This must be kept in sync with CameraHolder.
+var camera_distance = 2.0
+var base_height = ProjectSettings.get_setting("display/window/size/viewport_height")
+
+@onready var testers = $Testers
+@onready var camera_holder = $CameraHolder # Has a position and rotates on Y.
+@onready var rotation_x = $CameraHolder/RotationX
+@onready var camera = $CameraHolder/RotationX/Camera3D
+
+
+func _ready():
+	camera_holder.transform.basis = Basis.from_euler(Vector3(0, rot_y, 0))
+	rotation_x.transform.basis = Basis.from_euler(Vector3(rot_x, 0, 0))
+	update_gui()
+
+
+func _unhandled_input(event):
+	if event.is_action_pressed("ui_left"):
+		_on_previous_pressed()
+	if event.is_action_pressed("ui_right"):
+		_on_next_pressed()
+
+	if event is InputEventMouseButton:
+		if event.button_index == MOUSE_BUTTON_WHEEL_UP:
+			camera_distance -= ZOOM_SPEED
+		if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
+			camera_distance += ZOOM_SPEED
+		camera_distance = clamp(camera_distance, 1.5, 6)
+
+	if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
+		# Compensate motion speed to be resolution-independent (based on the window height).
+		var relative_motion = event.relative * DisplayServer.window_get_size().y / base_height
+		rot_y -= relative_motion.x * ROT_SPEED
+		rot_x -= relative_motion.y * ROT_SPEED
+		rot_x = clamp(rot_x, -1.57, 0)
+		camera_holder.transform.basis = Basis.from_euler(Vector3(0, rot_y, 0))
+		rotation_x.transform.basis = Basis.from_euler(Vector3(rot_x, 0, 0))
+
+
+func _process(delta):
+	var current_tester = testers.get_child(tester_index)
+	# This code assumes CameraHolder's X and Y coordinates are already correct.
+	var current_position = camera_holder.global_transform.origin.z
+	var target_position = current_tester.global_transform.origin.z
+	camera_holder.global_transform.origin.z = lerpf(current_position, target_position, 3 * delta)
+	camera.position.z = lerpf(camera.position.z, camera_distance, 10 * delta)
+
+
+func _on_previous_pressed():
+	tester_index = max(0, tester_index - 1)
+	update_gui()
+
+
+func _on_next_pressed():
+	tester_index = min(tester_index + 1, testers.get_child_count() - 1)
+	update_gui()
+
+
+func update_gui():
+	$TestName.text = str(testers.get_child(tester_index).name).capitalize()
+	$Previous.disabled = tester_index == 0
+	$Next.disabled = tester_index == testers.get_child_count() - 1
+
+	# Only display player name field if relevant.
+	$Testers/Label3DHealthBar/Name2.visible = str(testers.get_child(tester_index).name) == "Label3DHealthBar"
+	$Testers/Label3DHealthBar/LineEdit.visible = str(testers.get_child(tester_index).name) == "Label3DHealthBar"
+
+
+func _on_line_edit_text_submitted(new_text):
+	$Testers/Label3DHealthBar/LineEdit.release_focus()

+ 692 - 0
3d/labels_and_texts/3d_labels_and_texts.tscn

@@ -0,0 +1,692 @@
+[gd_scene load_steps=37 format=3 uid="uid://crd3is1f8w55h"]
+
+[ext_resource type="FontFile" uid="uid://cw4codbiaecjh" path="res://fonts/Xolonium-Regular.ttf" id="3_ds7iv"]
+[ext_resource type="FontFile" uid="uid://rv6to2i5stmy" path="res://fonts/Xolonium-Regular-MSDF.ttf" id="4_omdth"]
+[ext_resource type="FontFile" uid="uid://ueofyxhwry0c" path="res://fonts/Xolonium-Regular-MSDF-Mipmaps.ttf" id="5_syv27"]
+[ext_resource type="FontFile" uid="uid://ceawygbjffpls" path="res://fonts/Xolonium-Regular-Mipmaps.ttf" id="6_ewmy5"]
+[ext_resource type="Texture2D" uid="uid://bpgdsvb3lfg6l" path="res://textures/textmesh_texture.png" id="7_w00di"]
+[ext_resource type="FontFile" uid="uid://cb35jtyk02goi" path="res://fonts/fontello-godot.woff2" id="7_wvpht"]
+[ext_resource type="Shader" path="res://curvature.gdshader" id="8_2gwag"]
+[ext_resource type="Script" path="res://label_3d_layout.gd" id="8_rvw0p"]
+[ext_resource type="Texture2D" uid="uid://chjqieyps5n5r" path="res://textures/checker.png" id="14"]
+[ext_resource type="Script" path="res://3d_labels_and_texts.gd" id="18"]
+
+[sub_resource type="ProceduralSkyMaterial" id="9"]
+
+[sub_resource type="Sky" id="10"]
+sky_material = SubResource("9")
+
+[sub_resource type="Environment" id="11"]
+background_mode = 2
+sky = SubResource("10")
+
+[sub_resource type="Animation" id="Animation_qdnt6"]
+length = 0.001
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("Testers/Label3DFontTypes/AnimationOrigin:position")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0),
+"transitions": PackedFloat32Array(1),
+"update": 0,
+"values": [Vector3(0, 0, 0)]
+}
+
+[sub_resource type="Animation" id="12"]
+resource_name = "move"
+length = 10.0
+loop_mode = 1
+tracks/0/type = "value"
+tracks/0/imported = false
+tracks/0/enabled = true
+tracks/0/path = NodePath("Testers/Label3DFontTypes/AnimationOrigin:position")
+tracks/0/interp = 1
+tracks/0/loop_wrap = true
+tracks/0/keys = {
+"times": PackedFloat32Array(0, 5),
+"transitions": PackedFloat32Array(-2, -2),
+"update": 0,
+"values": [Vector3(2, 0, 0), Vector3(-13, 0, 0)]
+}
+
+[sub_resource type="AnimationLibrary" id="AnimationLibrary_ecfcr"]
+_data = {
+"RESET": SubResource("Animation_qdnt6"),
+"move": SubResource("12")
+}
+
+[sub_resource type="StandardMaterial3D" id="13"]
+diffuse_mode = 1
+albedo_texture = ExtResource("14")
+uv1_scale = Vector3(32, 32, 1)
+texture_filter = 5
+
+[sub_resource type="PlaneMesh" id="14"]
+material = SubResource("13")
+size = Vector2(128, 128)
+
+[sub_resource type="BoxMesh" id="BoxMesh_770hc"]
+size = Vector3(0.125, 1.5, 2.5)
+
+[sub_resource type="BoxMesh" id="BoxMesh_juuw1"]
+
+[sub_resource type="SphereMesh" id="SphereMesh_wsjfy"]
+
+[sub_resource type="FontVariation" id="FontVariation_hue2h"]
+spacing_glyph = -8
+
+[sub_resource type="TextMesh" id="TextMesh_xlu0q"]
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 64
+
+[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ri5nw"]
+albedo_color = Color(0.356863, 0.301961, 1, 1)
+
+[sub_resource type="TextMesh" id="TextMesh_u3elb"]
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 64
+
+[sub_resource type="TextMesh" id="TextMesh_u00sq"]
+text = "TextMesh (depth = 0.0)"
+font_size = 32
+depth = 0.0
+
+[sub_resource type="TextMesh" id="TextMesh_cf5wd"]
+text = "TextMesh"
+font_size = 32
+
+[sub_resource type="TextMesh" id="TextMesh_0mhsg"]
+text = "TextMesh (low detail)"
+font_size = 32
+curve_step = 10.0
+
+[sub_resource type="TextMesh" id="TextMesh_ddkjo"]
+text = "Additive Blending"
+font_size = 32
+
+[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_iyglb"]
+blend_mode = 1
+albedo_color = Color(0.776471, 1, 0.45098, 1)
+
+[sub_resource type="TextMesh" id="TextMesh_idsby"]
+text = "Metallic"
+font_size = 32
+
+[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mdg0l"]
+albedo_color = Color(1, 0.345098, 0.760784, 1)
+metallic = 1.0
+roughness = 0.0
+
+[sub_resource type="TextMesh" id="TextMesh_0sjgn"]
+text = "Curvature Shader"
+font_size = 32
+depth = 0.1
+
+[sub_resource type="ShaderMaterial" id="ShaderMaterial_iuh2c"]
+render_priority = 0
+shader = ExtResource("8_2gwag")
+
+[sub_resource type="TextMesh" id="TextMesh_fqc7s"]
+text = "Textured TextMesh"
+font_size = 32
+depth = 0.1
+
+[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_i3bnm"]
+shading_mode = 0
+albedo_texture = ExtResource("7_w00di")
+texture_filter = 0
+
+[node name="AntiAliasingTestScene" type="WorldEnvironment"]
+environment = SubResource("11")
+script = ExtResource("18")
+
+[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
+autoplay = "move"
+libraries = {
+"": SubResource("AnimationLibrary_ecfcr")
+}
+
+[node name="Plane" type="MeshInstance3D" parent="."]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -22)
+layers = 2
+mesh = SubResource("14")
+
+[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
+transform = Transform3D(0.909487, -0.23874, 0.340349, 0, 0.818672, 0.574262, -0.415733, -0.522284, 0.744571, 3.9506, 3.39961, 3.54442)
+shadow_enabled = true
+shadow_bias = 0.04
+shadow_blur = 1.5
+directional_shadow_mode = 0
+directional_shadow_fade_start = 1.0
+directional_shadow_max_distance = 24.0
+
+[node name="CameraHolder" type="Node3D" parent="."]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.125, 0)
+
+[node name="RotationX" type="Node3D" parent="CameraHolder"]
+
+[node name="Camera3D" type="Camera3D" parent="CameraHolder/RotationX"]
+fov = 70.0
+
+[node name="Testers" type="Node3D" parent="."]
+
+[node name="BasicLabel3D" type="Node3D" parent="Testers"]
+
+[node name="Label3D" type="Label3D" parent="Testers/BasicLabel3D"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.6, 0)
+texture_filter = 5
+outline_modulate = Color(0.270588, 0.270588, 0.270588, 1)
+text = "Hello from Label3D!
+
+Line breaks and/or autowrap can be used to write multiline text."
+outline_size = 3
+autowrap_mode = 2
+width = 460.0
+
+[node name="Wall" type="MeshInstance3D" parent="Testers/BasicLabel3D"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0654575, 0.5, 0)
+mesh = SubResource("BoxMesh_770hc")
+
+[node name="TwoSidedLabel3D" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -4)
+
+[node name="Front" type="Label3D" parent="Testers/TwoSidedLabel3D"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.7, 0)
+double_sided = false
+texture_filter = 5
+modulate = Color(0.686275, 0.92549, 1, 1)
+text = "Rotate to the other side…"
+font_size = 48
+outline_size = 3
+vertical_alignment = 0
+
+[node name="Back" type="Label3D" parent="Testers/TwoSidedLabel3D"]
+transform = Transform3D(1.31134e-07, 0, -1, 0, 1, 0, 1, 0, 1.31134e-07, 0, 0.7, 0)
+double_sided = false
+texture_filter = 5
+modulate = Color(1, 0.929412, 0.607843, 1)
+text = "Rotate to the other side…
+(second Label3D node)"
+font_size = 48
+outline_size = 3
+vertical_alignment = 0
+
+[node name="ShadedLabel3D" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -8)
+
+[node name="AlphaCutDisabled" type="Label3D" parent="Testers/ShadedLabel3D"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.3, 0)
+shaded = true
+texture_filter = 5
+modulate = Color(0.607843, 1, 1, 1)
+outline_modulate = Color(0, 0, 0, 0.501961)
+text = "Alpha Cut = Disabled
+I receive shadows"
+font_size = 48
+outline_size = 3
+line_spacing = -6.0
+
+[node name="AlphaCutDiscard" type="Label3D" parent="Testers/ShadedLabel3D"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.1, 0)
+cast_shadow = 1
+shaded = true
+alpha_cut = 1
+texture_filter = 5
+modulate = Color(0.843137, 0.623529, 1, 1)
+outline_modulate = Color(0, 0, 0, 0.501961)
+text = "Alpha Cut = Discard
+I cast and receive shadows
+(but can't have partial transparency)"
+font_size = 44
+outline_size = 3
+line_spacing = -6.0
+
+[node name="AlphaCutOpaquePrepass" type="Label3D" parent="Testers/ShadedLabel3D"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.9, 0)
+cast_shadow = 1
+shaded = true
+alpha_cut = 2
+texture_filter = 5
+modulate = Color(0.678431, 1, 0.713726, 1)
+outline_modulate = Color(0, 0, 0, 0.501961)
+text = "Alpha Cut = Opaque Prepass
+I cast and receive shadows"
+font_size = 48
+outline_size = 3
+line_spacing = -6.0
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="Testers/ShadedLabel3D"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2.71175, 1.61301)
+transparency = 0.33
+mesh = SubResource("BoxMesh_juuw1")
+
+[node name="Label3DFontTypes" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -12)
+
+[node name="AnimationOrigin" type="Node3D" parent="Testers/Label3DFontTypes"]
+
+[node name="Raster" type="Label3D" parent="Testers/Label3DFontTypes/AnimationOrigin"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.4, 1)
+texture_filter = 5
+text = "Label3D
+(raster)"
+font = ExtResource("3_ds7iv")
+font_size = 40
+outline_size = 9
+
+[node name="MSDF" type="Label3D" parent="Testers/Label3DFontTypes/AnimationOrigin"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.4, -1)
+texture_filter = 5
+text = "Label3D
+(MSDF)"
+font = ExtResource("4_omdth")
+font_size = 40
+outline_size = 9
+
+[node name="RasterMipmaps" type="Label3D" parent="Testers/Label3DFontTypes/AnimationOrigin"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.8, 1)
+texture_filter = 5
+text = "Label3D
+(raster +
+mipmaps)"
+font = ExtResource("6_ewmy5")
+font_size = 40
+outline_size = 9
+
+[node name="MSDFMipmaps" type="Label3D" parent="Testers/Label3DFontTypes/AnimationOrigin"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.8, -1)
+texture_filter = 5
+text = "Label3D
+(MSDF +
+mipmaps)"
+font = ExtResource("5_syv27")
+font_size = 40
+outline_size = 9
+
+[node name="Label3DBillboardModes" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -16)
+
+[node name="Disabled" type="Label3D" parent="Testers/Label3DBillboardModes"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.2, 1)
+texture_filter = 5
+modulate = Color(0.996078, 1, 0.333333, 1)
+text = "Disabled"
+font_size = 48
+outline_size = 3
+
+[node name="Enabled" type="Label3D" parent="Testers/Label3DBillboardModes"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.2, -1)
+billboard = 1
+texture_filter = 5
+modulate = Color(0.0784314, 0, 0.588235, 1)
+outline_modulate = Color(1, 1, 1, 0.301961)
+text = "Enabled"
+font_size = 48
+outline_size = 3
+
+[node name="YBillboard" type="Label3D" parent="Testers/Label3DBillboardModes"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.7, 0)
+billboard = 2
+texture_filter = 5
+modulate = Color(1, 0.313726, 0.454902, 1)
+outline_modulate = Color(0.384314, 0.188235, 0.188235, 1)
+text = "Y-Billboard"
+font_size = 48
+outline_size = 3
+
+[node name="Label3DDistanceFade" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -20)
+
+[node name="NoDistanceFade" type="Label3D" parent="Testers/Label3DDistanceFade"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.3, 1)
+texture_filter = 5
+modulate = Color(1, 0.741176, 0.831373, 1)
+text = "No
+Distance Fade"
+font_size = 40
+outline_size = 4
+
+[node name="DistanceFade" type="Label3D" parent="Testers/Label3DDistanceFade"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.3, -1)
+visibility_range_end = 5.0
+visibility_range_end_margin = 2.5
+visibility_range_fade_mode = 1
+texture_filter = 5
+modulate = Color(0.32549, 1, 0.858824, 1)
+text = "With
+Distance Fade"
+font_size = 40
+outline_size = 4
+
+[node name="NoDistanceFadeBillboard" type="Label3D" parent="Testers/Label3DDistanceFade"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.1, 1)
+billboard = 1
+texture_filter = 5
+modulate = Color(1, 0.741176, 0.831373, 1)
+text = "No
+Distance Fade
+(Billboard)"
+font_size = 40
+outline_size = 4
+
+[node name="DistanceFadeBillboard" type="Label3D" parent="Testers/Label3DDistanceFade"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.1, -1)
+visibility_range_end = 5.0
+visibility_range_end_margin = 2.5
+visibility_range_fade_mode = 1
+billboard = 1
+texture_filter = 5
+modulate = Color(0.32549, 1, 0.858824, 1)
+text = "With
+Distance Fade
+(Billboard)"
+font_size = 40
+outline_size = 4
+
+[node name="DistanceFadeFixedSize" type="Label3D" parent="Testers/Label3DDistanceFade"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -0.000778437, 0.50287, -1.90735e-05)
+visibility_range_end = 5.0
+visibility_range_end_margin = 2.5
+visibility_range_fade_mode = 1
+pixel_size = 0.001
+billboard = 1
+fixed_size = true
+texture_filter = 5
+modulate = Color(0.760784, 0.690196, 1, 1)
+text = "With
+Distance Fade
+(Billboard + Fixed Size)"
+font_size = 40
+outline_size = 4
+
+[node name="Label3DDepthTest" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -24)
+
+[node name="WithDepthTest" type="Label3D" parent="Testers/Label3DDepthTest"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.5, 1)
+texture_filter = 5
+modulate = Color(0.623529, 0.784314, 1, 1)
+text = "With Depth Test"
+font_size = 40
+outline_size = 4
+
+[node name="NoDepthTest" type="Label3D" parent="Testers/Label3DDepthTest"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.5, -1)
+no_depth_test = true
+texture_filter = 5
+modulate = Color(1, 0.607843, 0.290196, 1)
+text = "No Depth Test"
+font_size = 40
+outline_size = 4
+
+[node name="NoDepthTestXray" type="Label3D" parent="Testers/Label3DDepthTest"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1, -1)
+no_depth_test = true
+texture_filter = 5
+modulate = Color(1, 0.607843, 0.290196, 0.25098)
+outline_modulate = Color(0, 0, 0, 0.25098)
+text = "No Depth Test
+(X-Ray with second Label3D)"
+outline_size = 4
+
+[node name="DepthTestXray" type="Label3D" parent="Testers/Label3DDepthTest"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1, -1)
+texture_filter = 5
+modulate = Color(1, 0.607843, 0.290196, 1)
+text = "No Depth Test
+(X-Ray with second Label3D)"
+outline_size = 4
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="Testers/Label3DDepthTest"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9, 0.5, 0)
+mesh = SubResource("SphereMesh_wsjfy")
+
+[node name="Label3DIcons" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -28)
+
+[node name="Monochrome" type="Label3D" parent="Testers/Label3DIcons"]
+transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 0.4, 1)
+cast_shadow = 1
+billboard = 1
+alpha_cut = 1
+texture_filter = 5
+outline_render_priority = 1
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 128
+outline_size = 6
+
+[node name="Monochrome2" type="Label3D" parent="Testers/Label3DIcons"]
+transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 0.4, 0)
+cast_shadow = 1
+billboard = 1
+alpha_cut = 1
+texture_filter = 5
+outline_render_priority = 1
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 128
+outline_size = 6
+
+[node name="Monochrome3" type="Label3D" parent="Testers/Label3DIcons"]
+transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 0.4, -1)
+cast_shadow = 1
+billboard = 1
+alpha_cut = 1
+texture_filter = 5
+outline_render_priority = 1
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 128
+outline_size = 6
+
+[node name="ColorBlue" type="Label3D" parent="Testers/Label3DIcons"]
+transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 1.3, 0)
+cast_shadow = 1
+double_sided = false
+alpha_cut = 1
+texture_filter = 5
+modulate = Color(0.278431, 0.54902, 0.74902, 1)
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 96
+
+[node name="ColorWhite" type="Label3D" parent="Testers/Label3DIcons"]
+transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0.001, 1.3, 0)
+cast_shadow = 1
+double_sided = false
+alpha_cut = 1
+texture_filter = 5
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 96
+
+[node name="ColorGray" type="Label3D" parent="Testers/Label3DIcons"]
+transform = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0.002, 1.3, 0)
+cast_shadow = 1
+double_sided = false
+alpha_cut = 1
+texture_filter = 5
+modulate = Color(0.027451, 0.027451, 0.027451, 1)
+text = ""
+font = ExtResource("7_wvpht")
+font_size = 96
+
+[node name="Label3DHealthBar" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -32)
+script = ExtResource("8_rvw0p")
+
+[node name="Name" type="Label3D" parent="Testers/Label3DHealthBar"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.4, 0)
+extra_cull_margin = 1.0
+offset = Vector2(-160, 0)
+billboard = 1
+texture_filter = 5
+text = "Example"
+font = ExtResource("5_syv27")
+outline_size = 4
+horizontal_alignment = 0
+width = 230.0
+
+[node name="Health" type="Label3D" parent="Testers/Label3DHealthBar"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.4, 0)
+extra_cull_margin = 1.0
+offset = Vector2(120, 0)
+billboard = 1
+texture_filter = 5
+modulate = Color(0.8, 1, 0.4, 1)
+outline_modulate = Color(0.15, 0.2, 0.15, 1)
+text = "89%"
+font = ExtResource("5_syv27")
+outline_size = 4
+
+[node name="HealthBarForeground" type="Label3D" parent="Testers/Label3DHealthBar"]
+transform = Transform3D(-1.74846e-07, 0, 1, 0, 1, 0, -4, 0, -4.37114e-08, 0, 0.4, 0)
+extra_cull_margin = 1.0
+offset = Vector2(-45, -35)
+billboard = 1
+texture_filter = 5
+modulate = Color(0.8, 1, 0.4, 1)
+outline_modulate = Color(0.15, 0.2, 0.15, 1)
+text = "|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
+font = SubResource("FontVariation_hue2h")
+font_size = 16
+outline_size = 0
+horizontal_alignment = 0
+
+[node name="HealthBarBackground" type="Label3D" parent="Testers/Label3DHealthBar"]
+transform = Transform3D(-1.69382e-07, 0, 1, 0, 1, 0, -3.875, 0, -4.37114e-08, 0, 0.4, 0)
+extra_cull_margin = 1.0
+offset = Vector2(0, -35)
+billboard = 1
+texture_filter = 5
+render_priority = -1
+outline_render_priority = -2
+modulate = Color(0.15, 0.2, 0.15, 1)
+outline_modulate = Color(0.15, 0.2, 0.15, 1)
+text = "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
+font = SubResource("FontVariation_hue2h")
+font_size = 16
+outline_size = 6
+
+[node name="Name2" type="Label" parent="Testers/Label3DHealthBar"]
+offset_left = 16.0
+offset_top = 16.0
+offset_right = 193.0
+offset_bottom = 47.0
+text = "Name"
+vertical_alignment = 1
+
+[node name="LineEdit" type="LineEdit" parent="Testers/Label3DHealthBar"]
+offset_left = 88.0
+offset_top = 16.0
+offset_right = 236.0
+offset_bottom = 47.0
+text = "Example"
+caret_blink = true
+
+[node name="TextMesh" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, -36)
+
+[node name="IconAudio" type="MeshInstance3D" parent="Testers/TextMesh"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.4, 0.5)
+mesh = SubResource("TextMesh_xlu0q")
+surface_material_override/0 = SubResource("StandardMaterial3D_ri5nw")
+
+[node name="IconSuccess" type="MeshInstance3D" parent="Testers/TextMesh"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 1.4, -0.5)
+mesh = SubResource("TextMesh_u3elb")
+surface_material_override/0 = SubResource("StandardMaterial3D_ri5nw")
+
+[node name="NoDepth" type="MeshInstance3D" parent="Testers/TextMesh"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.9, 0)
+mesh = SubResource("TextMesh_u00sq")
+surface_material_override/0 = SubResource("StandardMaterial3D_ri5nw")
+
+[node name="Text" type="MeshInstance3D" parent="Testers/TextMesh"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.5, 0)
+mesh = SubResource("TextMesh_cf5wd")
+surface_material_override/0 = SubResource("StandardMaterial3D_ri5nw")
+
+[node name="LowDetail" type="MeshInstance3D" parent="Testers/TextMesh"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.1, 0)
+mesh = SubResource("TextMesh_0mhsg")
+surface_material_override/0 = SubResource("StandardMaterial3D_ri5nw")
+
+[node name="TextMeshEffects" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, -40)
+
+[node name="AdditiveBlending" type="MeshInstance3D" parent="Testers/TextMeshEffects"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.1, 0)
+mesh = SubResource("TextMesh_ddkjo")
+surface_material_override/0 = SubResource("StandardMaterial3D_iyglb")
+
+[node name="Metallic" type="MeshInstance3D" parent="Testers/TextMeshEffects"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.5, 0)
+mesh = SubResource("TextMesh_idsby")
+surface_material_override/0 = SubResource("StandardMaterial3D_mdg0l")
+
+[node name="CurvatureShader" type="MeshInstance3D" parent="Testers/TextMeshEffects"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.9, 0)
+mesh = SubResource("TextMesh_0sjgn")
+surface_material_override/0 = SubResource("ShaderMaterial_iuh2c")
+
+[node name="TextMeshTexture" type="Node3D" parent="Testers"]
+transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, -44)
+
+[node name="MeshInstance3D" type="MeshInstance3D" parent="Testers/TextMeshTexture"]
+transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0.1, 0)
+mesh = SubResource("TextMesh_fqc7s")
+surface_material_override/0 = SubResource("StandardMaterial3D_i3bnm")
+
+[node name="TestName" type="Label" parent="."]
+anchors_preset = 7
+anchor_left = 0.5
+anchor_top = 1.0
+anchor_right = 0.5
+anchor_bottom = 1.0
+offset_left = -192.0
+offset_top = -58.0
+offset_right = 192.0
+offset_bottom = -24.0
+grow_horizontal = 2
+grow_vertical = 0
+theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
+theme_override_constants/outline_size = 7
+theme_override_font_sizes/font_size = 24
+horizontal_alignment = 1
+
+[node name="Previous" type="Button" parent="."]
+anchors_preset = 2
+anchor_top = 1.0
+anchor_bottom = 1.0
+offset_left = 24.0
+offset_top = -55.0
+offset_right = 135.0
+offset_bottom = -24.0
+grow_vertical = 0
+text = "«  Previous"
+
+[node name="Next" type="Button" parent="."]
+anchors_preset = 3
+anchor_left = 1.0
+anchor_top = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_left = -107.0
+offset_top = -55.0
+offset_right = -24.0
+offset_bottom = -24.0
+grow_horizontal = 0
+grow_vertical = 0
+text = "Next  »"
+
+[connection signal="text_changed" from="Testers/Label3DHealthBar/LineEdit" to="Testers/Label3DHealthBar" method="_on_line_edit_text_changed"]
+[connection signal="text_submitted" from="Testers/Label3DHealthBar/LineEdit" to="." method="_on_line_edit_text_submitted"]
+[connection signal="pressed" from="Previous" to="." method="_on_previous_pressed"]
+[connection signal="pressed" from="Next" to="." method="_on_next_pressed"]

+ 39 - 0
3d/labels_and_texts/README.md

@@ -0,0 +1,39 @@
+# 3D Labels and Texts
+
+This project showcases the two main 3D text techniques supported by Godot:
+Label3D and TextMesh.
+
+Both Label3D and TextMesh exist in 3D space and can optionally be occluded by
+other objects, but they serve different use cases.
+
+**Label3D:** The Label3D node is a 3D node like any other. It draws text using
+one quad per character, which can optionally be set to work as a billboard.
+
+**TextMesh:** Unlike Label3D, TextMesh can optionally have actual depth since it
+generates geometry to represent the text. TextMesh is not a node, but a
+PrimitiveMesh resource you use within a MeshsInstance3D node. Therefore, you
+won't see TextMesh in the Create New Node dialog.
+
+Icons can also be displayed in Label3D and TextMesh using icon fonts, which can
+be generated from SVG files using serivces like
+[Fontello](https://fontello.com/). Note that while Label3D supports colored
+rasterized fonts (such as emoji), only monochrome fonts can be generated from
+Fontello. TextMesh and Label3D with MSDF fonts are limited to monochrome fonts
+too.
+
+Both standard rasterized and MSDF fonts can be used in Label3D, while TextMesh
+will only support fonts that can be drawn as MSDF well. This excludes fonts that
+have self-intersecting outlines, which Godot currently doesn't handle well when
+converting them to MSDF.
+
+In most scenarios, Label3D is easier to use and can look better (thanks to
+outlines and MSDF rendering). TextMesh is more powerful and is intended for more
+specialized use cases.
+
+Language: GDScript
+
+Renderer: Vulkan Clustered
+
+## Screenshots
+
+![Screenshot](screenshots/3d_labels_and_texts.png)

+ 10 - 0
3d/labels_and_texts/curvature.gdshader

@@ -0,0 +1,10 @@
+shader_type spatial;
+
+void vertex() {
+	VERTEX.z -= 0.6 - cos(VERTEX.x) * 0.6;
+	VERTEX.x *= 0.8 + cos(VERTEX.x) * 0.2;
+}
+
+void fragment() {
+	ALBEDO = vec3(1.0, 0.6, 0.1);
+}

+ 7 - 0
3d/labels_and_texts/default_env.tres

@@ -0,0 +1,7 @@
+[gd_resource type="Environment" load_steps=2 format=2]
+
+[sub_resource type="Sky" id=1]
+
+[resource]
+background_mode = 2
+sky = SubResource( 1 )

BIN
3d/labels_and_texts/fonts/Xolonium-Regular-MSDF-Mipmaps.ttf


+ 33 - 0
3d/labels_and_texts/fonts/Xolonium-Regular-MSDF-Mipmaps.ttf.import

@@ -0,0 +1,33 @@
+[remap]
+
+importer="font_data_dynamic"
+type="FontFile"
+uid="uid://ueofyxhwry0c"
+path="res://.godot/imported/Xolonium-Regular-MSDF-Mipmaps.ttf-f9a30ae6846e38c4b1784d4a99043eef.fontdata"
+
+[deps]
+
+source_file="res://fonts/Xolonium-Regular-MSDF-Mipmaps.ttf"
+dest_files=["res://.godot/imported/Xolonium-Regular-MSDF-Mipmaps.ttf-f9a30ae6846e38c4b1784d4a99043eef.fontdata"]
+
+[params]
+
+Rendering=null
+antialiasing=1
+generate_mipmaps=true
+multichannel_signed_distance_field=true
+msdf_pixel_range=8
+msdf_size=48
+allow_system_fallback=true
+force_autohinter=false
+hinting=1
+subpixel_positioning=1
+oversampling=0.0
+Fallbacks=null
+fallbacks=[]
+Compress=null
+compress=true
+preload=[]
+language_support={}
+script_support={}
+opentype_features={}

BIN
3d/labels_and_texts/fonts/Xolonium-Regular-MSDF.ttf


+ 33 - 0
3d/labels_and_texts/fonts/Xolonium-Regular-MSDF.ttf.import

@@ -0,0 +1,33 @@
+[remap]
+
+importer="font_data_dynamic"
+type="FontFile"
+uid="uid://rv6to2i5stmy"
+path="res://.godot/imported/Xolonium-Regular-MSDF.ttf-07982cfb47cf7a997ebff6be3d79b5d9.fontdata"
+
+[deps]
+
+source_file="res://fonts/Xolonium-Regular-MSDF.ttf"
+dest_files=["res://.godot/imported/Xolonium-Regular-MSDF.ttf-07982cfb47cf7a997ebff6be3d79b5d9.fontdata"]
+
+[params]
+
+Rendering=null
+antialiasing=1
+generate_mipmaps=false
+multichannel_signed_distance_field=true
+msdf_pixel_range=8
+msdf_size=48
+allow_system_fallback=true
+force_autohinter=false
+hinting=1
+subpixel_positioning=1
+oversampling=0.0
+Fallbacks=null
+fallbacks=[]
+Compress=null
+compress=true
+preload=[]
+language_support={}
+script_support={}
+opentype_features={}

BIN
3d/labels_and_texts/fonts/Xolonium-Regular-Mipmaps.ttf


+ 33 - 0
3d/labels_and_texts/fonts/Xolonium-Regular-Mipmaps.ttf.import

@@ -0,0 +1,33 @@
+[remap]
+
+importer="font_data_dynamic"
+type="FontFile"
+uid="uid://ceawygbjffpls"
+path="res://.godot/imported/Xolonium-Regular-Mipmaps.ttf-ad14e01c6ec957f8c9fcd447a39103b1.fontdata"
+
+[deps]
+
+source_file="res://fonts/Xolonium-Regular-Mipmaps.ttf"
+dest_files=["res://.godot/imported/Xolonium-Regular-Mipmaps.ttf-ad14e01c6ec957f8c9fcd447a39103b1.fontdata"]
+
+[params]
+
+Rendering=null
+antialiasing=1
+generate_mipmaps=true
+multichannel_signed_distance_field=false
+msdf_pixel_range=8
+msdf_size=48
+allow_system_fallback=true
+force_autohinter=false
+hinting=1
+subpixel_positioning=1
+oversampling=0.0
+Fallbacks=null
+fallbacks=[]
+Compress=null
+compress=true
+preload=[]
+language_support={}
+script_support={}
+opentype_features={}

BIN
3d/labels_and_texts/fonts/Xolonium-Regular.ttf


+ 33 - 0
3d/labels_and_texts/fonts/Xolonium-Regular.ttf.import

@@ -0,0 +1,33 @@
+[remap]
+
+importer="font_data_dynamic"
+type="FontFile"
+uid="uid://cw4codbiaecjh"
+path="res://.godot/imported/Xolonium-Regular.ttf-bc2981e3069cff4c34dd7c8e2bb73fba.fontdata"
+
+[deps]
+
+source_file="res://fonts/Xolonium-Regular.ttf"
+dest_files=["res://.godot/imported/Xolonium-Regular.ttf-bc2981e3069cff4c34dd7c8e2bb73fba.fontdata"]
+
+[params]
+
+Rendering=null
+antialiasing=1
+generate_mipmaps=false
+multichannel_signed_distance_field=false
+msdf_pixel_range=8
+msdf_size=48
+allow_system_fallback=true
+force_autohinter=false
+hinting=1
+subpixel_positioning=1
+oversampling=0.0
+Fallbacks=null
+fallbacks=[]
+Compress=null
+compress=true
+preload=[]
+language_support={}
+script_support={}
+opentype_features={}

File diff suppressed because it is too large
+ 15 - 0
3d/labels_and_texts/fonts/config.json


BIN
3d/labels_and_texts/fonts/fontello-godot.woff2


+ 33 - 0
3d/labels_and_texts/fonts/fontello-godot.woff2.import

@@ -0,0 +1,33 @@
+[remap]
+
+importer="font_data_dynamic"
+type="FontFile"
+uid="uid://cb35jtyk02goi"
+path="res://.godot/imported/fontello-godot.woff2-b335626e1a658a7c7c74969daeb4c6c1.fontdata"
+
+[deps]
+
+source_file="res://fonts/fontello-godot.woff2"
+dest_files=["res://.godot/imported/fontello-godot.woff2-b335626e1a658a7c7c74969daeb4c6c1.fontdata"]
+
+[params]
+
+Rendering=null
+antialiasing=1
+generate_mipmaps=true
+multichannel_signed_distance_field=false
+msdf_pixel_range=8
+msdf_size=48
+allow_system_fallback=true
+force_autohinter=false
+hinting=1
+subpixel_positioning=1
+oversampling=0.0
+Fallbacks=null
+fallbacks=[]
+Compress=null
+compress=true
+preload=[]
+language_support={}
+script_support={}
+opentype_features={}

BIN
3d/labels_and_texts/icon.png


+ 36 - 0
3d/labels_and_texts/icon.png.import

@@ -0,0 +1,36 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://8c1xtc7yj6s5"
+path.s3tc="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.ctex"
+path.etc2="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.etc2.ctex"
+metadata={
+"imported_formats": ["s3tc", "etc2"],
+"vram_texture": true
+}
+
+[deps]
+
+source_file="res://icon.png"
+dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.ctex", "res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.etc2.ctex"]
+
+[params]
+
+compress/mode=2
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/bptc_ldr=0
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=true
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0

+ 68 - 0
3d/labels_and_texts/label_3d_layout.gd

@@ -0,0 +1,68 @@
+# Layout is simulated by adjusting Label3Ds' `offset` properties.
+# This can be done in the inspector, or via code with the help of `Font.get_string_size()`.
+# For proper billboard behavior, Label3D's `offset` property
+# must be adjusted instead of adjusting the `position` property.
+extends Node3D
+
+var health = 0
+var counter = 0.0
+
+# The margin to apply between the name and health percentage (in pixels).
+const HEALTH_MARGIN = 25
+
+# The health bar width (in number of characters).
+# Higher can be more precise, at the cost of lower performance
+# (since more characters may need to be rendered at once).
+const BAR_WIDTH = 100
+
+
+func _ready():
+	$LineEdit.text = $Name.text
+
+
+func _process(delta):
+	# Animate the health percentage.
+	counter += delta
+	set_health(50 + sin(counter * 0.5) * 50)
+
+
+func set_health(p_health):
+	health = p_health
+
+	$Health.text = "%d%%" % round(health)
+	if health <= 30:
+		# Low health alert.
+		$Health.modulate = Color(1, 0.2, 0.1)
+		$Health.outline_modulate = Color(0.2, 0.1, 0.0)
+		$HealthBarForeground.modulate = Color(1, 0.2, 0.1)
+		$HealthBarForeground.outline_modulate = Color(0.2, 0.1, 0.0)
+		$HealthBarBackground.outline_modulate = Color(0.2, 0.1, 0.0)
+		$HealthBarBackground.modulate = Color(0.2, 0.1, 0.0)
+	else:
+		$Health.modulate = Color(0.8, 1, 0.4)
+		$Health.outline_modulate = Color(0.15, 0.2, 0.15)
+		$HealthBarForeground.modulate = Color(0.8, 1, 0.4)
+		$HealthBarForeground.outline_modulate = Color(0.15, 0.2, 0.15)
+		$HealthBarBackground.outline_modulate = Color(0.15, 0.2, 0.15)
+		$HealthBarBackground.modulate = Color(0.15, 0.2, 0.15)
+
+	# Construct an health bar with `|` symbols brought very close to each other using
+	# a custom FontVariation on the HealthBarForeground and HealthBarBackground nodes.
+	var bar_text = ""
+	var bar_text_bg = ""
+	for i in round((health / 100.0) * BAR_WIDTH):
+		bar_text += "|"
+	for i in BAR_WIDTH:
+		bar_text_bg += "|"
+
+	$HealthBarForeground.text = str(bar_text)
+	$HealthBarBackground.text = str(bar_text_bg)
+
+
+func _on_line_edit_text_changed(new_text):
+	$Name.text = new_text
+
+	# Adjust name's font size to fit within the allowed width.
+	$Name.font_size = 32
+	while $Name.font.get_string_size($Name.text, $Name.horizontal_alignment, -1, $Name.font_size).x > $Name.width:
+		$Name.font_size -= 1

+ 36 - 0
3d/labels_and_texts/project.godot

@@ -0,0 +1,36 @@
+; Engine configuration file.
+; It's best edited using the editor UI and not directly,
+; since the parameters that go here are not all obvious.
+;
+; Format:
+;   [section] ; section goes between []
+;   param=value ; assign values to parameters
+
+config_version=5
+
+_global_script_classes=[]
+_global_script_class_icons={}
+
+[application]
+
+config/name="3D Labels and Texts"
+config/description="This project showcases 2 ways to draw text in 3D space: the Label3D node, and MeshInstance3D with a TextMesh primitive."
+run/main_scene="res://3d_labels_and_texts.tscn"
+config/features=PackedStringArray("4.0")
+config/icon="res://icon.png"
+
+[display]
+
+window/stretch/mode="canvas_items"
+window/stretch/aspect="expand"
+
+[gui]
+
+theme/default_font_multichannel_signed_distance_field=true
+theme/default_font_generate_mipmaps=true
+
+[rendering]
+
+textures/default_filters/anisotropic_filtering_level=4
+quality/screen_filters/msaa=3
+environment/default_environment="res://default_env.tres"

+ 0 - 0
3d/labels_and_texts/screenshots/.gdignore


BIN
3d/labels_and_texts/screenshots/3d_labels_and_texts.png


+ 7 - 0
3d/labels_and_texts/textures/checker.LICENSE.md

@@ -0,0 +1,7 @@
+# License for `checker.png`
+
+Copyright (c) 2020 Kenney
+
+Licensed under CC0 1.0 Universal.
+
+Downloaded from https://kenney.nl/assets/prototype-textures

BIN
3d/labels_and_texts/textures/checker.png


+ 36 - 0
3d/labels_and_texts/textures/checker.png.import

@@ -0,0 +1,36 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://chjqieyps5n5r"
+path.s3tc="res://.godot/imported/checker.png-d334a8ae07de292fd4162f184b9dd7bc.s3tc.ctex"
+path.etc2="res://.godot/imported/checker.png-d334a8ae07de292fd4162f184b9dd7bc.etc2.ctex"
+metadata={
+"imported_formats": ["s3tc", "etc2"],
+"vram_texture": true
+}
+
+[deps]
+
+source_file="res://textures/checker.png"
+dest_files=["res://.godot/imported/checker.png-d334a8ae07de292fd4162f184b9dd7bc.s3tc.ctex", "res://.godot/imported/checker.png-d334a8ae07de292fd4162f184b9dd7bc.etc2.ctex"]
+
+[params]
+
+compress/mode=2
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/bptc_ldr=0
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=true
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0

+ 7 - 0
3d/labels_and_texts/textures/textmesh_texture.LICENSE.md

@@ -0,0 +1,7 @@
+# License for `textmesh_texture.png`
+
+Copyright (c) 2022 bruvzg
+
+Licensed under CC0 1.0 Universal.
+
+Downloaded from the test project linked in https://github.com/godotengine/godot/pull/60507

BIN
3d/labels_and_texts/textures/textmesh_texture.png


+ 34 - 0
3d/labels_and_texts/textures/textmesh_texture.png.import

@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://bpgdsvb3lfg6l"
+path="res://.godot/imported/textmesh_texture.png-8e64edd3f229f551dcbd8de816e37b7d.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://textures/textmesh_texture.png"
+dest_files=["res://.godot/imported/textmesh_texture.png-8e64edd3f229f551dcbd8de816e37b7d.ctex"]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/bptc_ldr=0
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=true
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=0

Some files were not shown because too many files changed in this diff