Skip to content

Label3D

Inherits: GeometryInstance3D < VisualInstance3D < Entity3D < Entity < Object

A node for displaying plain text in 3D space.

A node for displaying plain text in 3D space. By adjusting various properties of this node, you can configure things such as the text’s appearance and whether it always faces the camera.

Type Name Default
float alpha_antialiasing_edge 0.0
BaseMaterial3D.AlphaAntiAliasing alpha_antialiasing_mode 0
AlphaCutMode alpha_cut 0
float alpha_hash_scale 1.0
float alpha_scissor_threshold 0.5
TextSystem.AutowrapMode autowrap_mode 0
BitField[TextSystem.LineBreakFlag] autowrap_trim_flags 192
BaseMaterial3D.BillboardMode billboard 0
GeometryInstance3D.ShadowCastingSetting cast_shadow 0 (overrides GeometryInstance3D)
bool double_sided true
bool fixed_size false
Font font
int font_size 32
GeometryInstance3D.GIMode gi_mode 0 (overrides GeometryInstance3D)
HorizontalAlignment horizontal_alignment 1
BitField[TextSystem.JustificationFlag] justification_flags 163
String language ""
float line_spacing 0.0
Color modulate Color(1, 1, 1, 1)
bool no_depth_test false
Vector2 offset Vector2(0, 0)
Color outline_modulate Color(0, 0, 0, 1)
int outline_render_priority -1
int outline_size 12
float pixel_size 0.005
int render_priority 0
bool shaded false
TextSystem.StructuredTextParser structured_text_bidi_override 0
Array structured_text_bidi_override_options []
String text ""
TextSystem.Direction text_direction 0
BaseMaterial3D.TextureFilter texture_filter 3
bool uppercase false
VerticalAlignment vertical_alignment 1
float width 500.0
Returns Method
TriangleMesh generate_triangle_mesh() const
bool get_draw_flag(flag: DrawFlags) const
void set_draw_flag(flag: DrawFlags, enabled: bool)

DrawFlags

enum DrawFlags

FLAG_SHADED = 0

If set, lights in the environment affect the label.

FLAG_DOUBLE_SIDED = 1

If set, text can be seen from the back as well. If not, the text is invisible when looking at it from behind.

FLAG_DISABLE_DEPTH_TEST = 2

Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.

FLAG_FIXED_SIZE = 3

Label is scaled by depth so that it always appears the same size on screen.

FLAG_MAX = 4

Represents the size of the DrawFlags enum.

AlphaCutMode

enum AlphaCutMode

ALPHA_CUT_DISABLED = 0

This mode performs standard alpha blending. It can display translucent areas, but transparency sorting issues may be visible when multiple transparent materials are overlapping. GeometryInstance3D.cast_shadow has no effect when this transparency mode is used; the Label3D will never cast shadows.

ALPHA_CUT_DISCARD = 1

This mode only allows fully transparent or fully opaque pixels. Harsh edges will be visible unless some form of screen-space antialiasing is enabled (see ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa). This mode is also known as alpha testing or 1-bit transparency.

Note: This mode might have issues with anti-aliased fonts and outlines, try adjusting alpha_scissor_threshold or using MSDF font.

Note: When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.

ALPHA_CUT_OPAQUE_PREPASS = 2

This mode draws fully opaque pixels in the depth prepass. This is slower than ALPHA_CUT_DISABLED or ALPHA_CUT_DISCARD, but it allows displaying translucent areas and smooth edges while using proper sorting.

Note: When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.

ALPHA_CUT_HASH = 3

This mode draws cuts off all values below a spatially-deterministic threshold, the rest will remain opaque.

alpha_antialiasing_edge

float alpha_antialiasing_edge = 0.0

Threshold at which antialiasing will be applied on the alpha channel.

alpha_antialiasing_mode

BaseMaterial3D.AlphaAntiAliasing alpha_antialiasing_mode = 0

The type of alpha antialiasing to apply.

alpha_cut

AlphaCutMode alpha_cut = 0

The alpha cutting mode to use for the sprite.

alpha_hash_scale

float alpha_hash_scale = 1.0

The hashing scale for Alpha Hash. Recommended values between 0 and 2.

alpha_scissor_threshold

float alpha_scissor_threshold = 0.5

Threshold at which the alpha scissor will discard values.

autowrap_mode

TextSystem.AutowrapMode autowrap_mode = 0

If set to something other than TextSystem.AUTOWRAP_OFF, the text gets wrapped inside the node’s bounding rectangle. If you resize the node, it will change its height automatically to show all the text.

autowrap_trim_flags

BitField[TextSystem.LineBreakFlag] autowrap_trim_flags = 192

Autowrap space trimming flags. See TextSystem.BREAK_TRIM_START_EDGE_SPACES and TextSystem.BREAK_TRIM_END_EDGE_SPACES for more info.

billboard

BaseMaterial3D.BillboardMode billboard = 0

The billboard mode to use for the label.

double_sided

bool double_sided = true

If true, text can be seen from the back as well, if false, it is invisible when looking at it from behind.

fixed_size

bool fixed_size = false

If true, the label is rendered at the same size regardless of distance. The label’s size on screen is the same as if the camera was 1.0 units away from the label’s origin, regardless of the actual distance from the camera. The Camera3D’s field of view (or Camera3D.size when in orthogonal/frustum mode) still affects the size the label is drawn at.

font

Font font

Font configuration used to display text.

font_size

int font_size = 32

Font size of the Label3D’s text. To make the font look more detailed when up close, increase font_size while decreasing pixel_size at the same time.

Higher font sizes require more time to render new characters, which can cause stuttering during gameplay.

horizontal_alignment

HorizontalAlignment horizontal_alignment = 1

Controls the text’s horizontal alignment. Supports left, center, right, and fill (also known as justify).

justification_flags

BitField[TextSystem.JustificationFlag] justification_flags = 163

Line fill alignment rules.

language

String language = ""

Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.

line_spacing

float line_spacing = 0.0

Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.

modulate

Color modulate = Color(1, 1, 1, 1)

Text Color of the Label3D.

no_depth_test

bool no_depth_test = false

If true, depth testing is disabled and the object will be drawn in render order.

offset

Vector2 offset = Vector2(0, 0)

The text drawing offset (in pixels).

outline_modulate

Color outline_modulate = Color(0, 0, 0, 1)

The tint of text outline.

outline_render_priority

int outline_render_priority = -1

Sets the render priority for the text outline. Higher priority objects will be sorted in front of lower priority objects.

Note: This only applies if alpha_cut is set to ALPHA_CUT_DISABLED (default value).

Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).

outline_size

int outline_size = 12

Text outline size.

pixel_size

float pixel_size = 0.005

The size of one pixel’s width on the label to scale it in 3D. To make the font look more detailed when up close, increase font_size while decreasing pixel_size at the same time.

render_priority

int render_priority = 0

Sets the render priority for the text. Higher priority objects will be sorted in front of lower priority objects.

Note: This only applies if alpha_cut is set to ALPHA_CUT_DISABLED (default value).

Note: This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority).

shaded

bool shaded = false

If true, the Light3D in the Environment has effects on the label.

structured_text_bidi_override

TextSystem.StructuredTextParser structured_text_bidi_override = 0

Set BiDi algorithm override for the structured text.

structured_text_bidi_override_options

Array structured_text_bidi_override_options = []

Set additional options for BiDi override.

text

String text = ""

The text to display on screen.

text_direction

TextSystem.Direction text_direction = 0

Base text writing direction.

texture_filter

BaseMaterial3D.TextureFilter texture_filter = 3

Filter flags for the texture.

uppercase

bool uppercase = false

If true, all the text displays as UPPERCASE.

vertical_alignment

VerticalAlignment vertical_alignment = 1

Controls the text’s vertical alignment. Supports top, center, and bottom.

width

float width = 500.0

Text width (in pixels), used for autowrap and fill alignment.

generate_triangle_mesh

TriangleMesh generate_triangle_mesh() const

Returns a TriangleMesh with the label’s vertices following its current configuration (such as its pixel_size).

get_draw_flag

bool get_draw_flag(flag: DrawFlags) const

Returns the value of the specified flag.

set_draw_flag

void set_draw_flag(flag: DrawFlags, enabled: bool)

If true, the specified flag will be enabled.