github_url: | hide |
---|
Inherits: :ref:`GeometryInstance3D<class_GeometryInstance3D>` < :ref:`VisualInstance3D<class_VisualInstance3D>` < :ref:`Node3D<class_Node3D>` < :ref:`Node<class_Node>` < :ref:`Object<class_Object>`
Inherited By: :ref:`AnimatedSprite3D<class_AnimatedSprite3D>`, :ref:`Sprite3D<class_Sprite3D>`
2D sprite node in 3D environment.
.. rst-class:: classref-introduction-group
A node that displays 2D texture information in a 3D environment. See also :ref:`Sprite3D<class_Sprite3D>` where many other properties are defined.
.. rst-class:: classref-reftable-group
.. rst-class:: classref-reftable-group
.. rst-class:: classref-section-separator
.. rst-class:: classref-descriptions-group
.. rst-class:: classref-enumeration
enum DrawFlags: :ref:`🔗<enum_SpriteBase3D_DrawFlags>`
.. rst-class:: classref-enumeration-constant
:ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` FLAG_TRANSPARENT = 0
If set, the texture's transparency and the opacity are used to make those parts of the sprite invisible.
.. rst-class:: classref-enumeration-constant
:ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` FLAG_SHADED = 1
If set, lights in the environment affect the sprite.
.. rst-class:: classref-enumeration-constant
:ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` FLAG_DOUBLE_SIDED = 2
If set, texture can be seen from the back as well. If not, the texture is invisible when looking at it from behind.
.. rst-class:: classref-enumeration-constant
:ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` FLAG_DISABLE_DEPTH_TEST = 3
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.
.. rst-class:: classref-enumeration-constant
:ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` FLAG_FIXED_SIZE = 4
Label is scaled by depth so that it always appears the same size on screen.
.. rst-class:: classref-enumeration-constant
:ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` FLAG_MAX = 5
Represents the size of the :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` enum.
.. rst-class:: classref-item-separator
.. rst-class:: classref-enumeration
enum AlphaCutMode: :ref:`🔗<enum_SpriteBase3D_AlphaCutMode>`
.. rst-class:: classref-enumeration-constant
:ref:`AlphaCutMode<enum_SpriteBase3D_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.
.. rst-class:: classref-enumeration-constant
:ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` 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 :ref:`ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa<class_ProjectSettings_property_rendering/anti_aliasing/quality/screen_space_aa>`). On the bright side, this mode doesn't suffer from transparency sorting issues when multiple transparent materials are overlapping. This mode is also known as alpha testing or 1-bit transparency.
.. rst-class:: classref-enumeration-constant
:ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` ALPHA_CUT_OPAQUE_PREPASS = 2
This mode draws fully opaque pixels in the depth prepass. This is slower than :ref:`ALPHA_CUT_DISABLED<class_SpriteBase3D_constant_ALPHA_CUT_DISABLED>` or :ref:`ALPHA_CUT_DISCARD<class_SpriteBase3D_constant_ALPHA_CUT_DISCARD>`, but it allows displaying translucent areas and smooth edges while using proper sorting.
.. rst-class:: classref-enumeration-constant
:ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` ALPHA_CUT_HASH = 3
This mode draws cuts off all values below a spatially-deterministic threshold, the rest will remain opaque.
.. rst-class:: classref-section-separator
.. rst-class:: classref-descriptions-group
.. rst-class:: classref-property
:ref:`float<class_float>` alpha_antialiasing_edge = 0.0
:ref:`🔗<class_SpriteBase3D_property_alpha_antialiasing_edge>`
.. rst-class:: classref-property-setget
- |void| set_alpha_antialiasing_edge(value: :ref:`float<class_float>`)
- :ref:`float<class_float>` get_alpha_antialiasing_edge()
Threshold at which antialiasing will be applied on the alpha channel.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`AlphaAntiAliasing<enum_BaseMaterial3D_AlphaAntiAliasing>` alpha_antialiasing_mode = 0
:ref:`🔗<class_SpriteBase3D_property_alpha_antialiasing_mode>`
.. rst-class:: classref-property-setget
- |void| set_alpha_antialiasing(value: :ref:`AlphaAntiAliasing<enum_BaseMaterial3D_AlphaAntiAliasing>`)
- :ref:`AlphaAntiAliasing<enum_BaseMaterial3D_AlphaAntiAliasing>` get_alpha_antialiasing()
The type of alpha antialiasing to apply. See :ref:`AlphaAntiAliasing<enum_BaseMaterial3D_AlphaAntiAliasing>`.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` alpha_cut = 0
:ref:`🔗<class_SpriteBase3D_property_alpha_cut>`
.. rst-class:: classref-property-setget
- |void| set_alpha_cut_mode(value: :ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>`)
- :ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` get_alpha_cut_mode()
The alpha cutting mode to use for the sprite. See :ref:`AlphaCutMode<enum_SpriteBase3D_AlphaCutMode>` for possible values.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`float<class_float>` alpha_hash_scale = 1.0
:ref:`🔗<class_SpriteBase3D_property_alpha_hash_scale>`
.. rst-class:: classref-property-setget
- |void| set_alpha_hash_scale(value: :ref:`float<class_float>`)
- :ref:`float<class_float>` get_alpha_hash_scale()
The hashing scale for Alpha Hash. Recommended values between 0
and 2
.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`float<class_float>` alpha_scissor_threshold = 0.5
:ref:`🔗<class_SpriteBase3D_property_alpha_scissor_threshold>`
.. rst-class:: classref-property-setget
- |void| set_alpha_scissor_threshold(value: :ref:`float<class_float>`)
- :ref:`float<class_float>` get_alpha_scissor_threshold()
Threshold at which the alpha scissor will discard values.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
Vector3.Axis axis = 2
:ref:`🔗<class_SpriteBase3D_property_axis>`
.. rst-class:: classref-property-setget
- |void| set_axis(value: Vector3.Axis)
- Vector3.Axis get_axis()
The direction in which the front of the texture faces.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>` billboard = 0
:ref:`🔗<class_SpriteBase3D_property_billboard>`
.. rst-class:: classref-property-setget
- |void| set_billboard_mode(value: :ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>`)
- :ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>` get_billboard_mode()
The billboard mode to use for the sprite. See :ref:`BillboardMode<enum_BaseMaterial3D_BillboardMode>` for possible values.
Note: When billboarding is enabled and the material also casts shadows, billboards will face the camera in the scene when rendering shadows. In scenes with multiple cameras, the intended shadow cannot be determined and this will result in undefined behavior. See GitHub Pull Request #72638 for details.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` centered = true
:ref:`🔗<class_SpriteBase3D_property_centered>`
.. rst-class:: classref-property-setget
- |void| set_centered(value: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` is_centered()
If true
, texture will be centered.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` double_sided = true
:ref:`🔗<class_SpriteBase3D_property_double_sided>`
.. rst-class:: classref-property-setget
- |void| set_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`, enabled: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` get_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`) |const|
If true
, texture can be seen from the back as well, if false
, it is invisible when looking at it from behind.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` fixed_size = false
:ref:`🔗<class_SpriteBase3D_property_fixed_size>`
.. rst-class:: classref-property-setget
- |void| set_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`, enabled: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` get_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`) |const|
If true
, the label is rendered at the same size regardless of distance.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` flip_h = false
:ref:`🔗<class_SpriteBase3D_property_flip_h>`
.. rst-class:: classref-property-setget
- |void| set_flip_h(value: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` is_flipped_h()
If true
, texture is flipped horizontally.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` flip_v = false
:ref:`🔗<class_SpriteBase3D_property_flip_v>`
.. rst-class:: classref-property-setget
- |void| set_flip_v(value: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` is_flipped_v()
If true
, texture is flipped vertically.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`Color<class_Color>` modulate = Color(1, 1, 1, 1)
:ref:`🔗<class_SpriteBase3D_property_modulate>`
.. rst-class:: classref-property-setget
- |void| set_modulate(value: :ref:`Color<class_Color>`)
- :ref:`Color<class_Color>` get_modulate()
A color value used to multiply the texture's colors. Can be used for mood-coloring or to simulate the color of ambient light.
Note: Unlike :ref:`CanvasItem.modulate<class_CanvasItem_property_modulate>` for 2D, colors with values above 1.0
(overbright) are not supported.
Note: If a :ref:`GeometryInstance3D.material_override<class_GeometryInstance3D_property_material_override>` is defined on the SpriteBase3D, the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in :ref:`modulate<class_SpriteBase3D_property_modulate>` will be ignored. For a :ref:`BaseMaterial3D<class_BaseMaterial3D>`, :ref:`BaseMaterial3D.vertex_color_use_as_albedo<class_BaseMaterial3D_property_vertex_color_use_as_albedo>` must be true
. For a :ref:`ShaderMaterial<class_ShaderMaterial>`, ALBEDO *= COLOR.rgb;
must be inserted in the shader's fragment()
function.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` no_depth_test = false
:ref:`🔗<class_SpriteBase3D_property_no_depth_test>`
.. rst-class:: classref-property-setget
- |void| set_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`, enabled: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` get_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`) |const|
If true
, depth testing is disabled and the object will be drawn in render order.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`Vector2<class_Vector2>` offset = Vector2(0, 0)
:ref:`🔗<class_SpriteBase3D_property_offset>`
.. rst-class:: classref-property-setget
- |void| set_offset(value: :ref:`Vector2<class_Vector2>`)
- :ref:`Vector2<class_Vector2>` get_offset()
The texture's drawing offset.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`float<class_float>` pixel_size = 0.01
:ref:`🔗<class_SpriteBase3D_property_pixel_size>`
.. rst-class:: classref-property-setget
- |void| set_pixel_size(value: :ref:`float<class_float>`)
- :ref:`float<class_float>` get_pixel_size()
The size of one pixel's width on the sprite to scale it in 3D.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`int<class_int>` render_priority = 0
:ref:`🔗<class_SpriteBase3D_property_render_priority>`
.. rst-class:: classref-property-setget
- |void| set_render_priority(value: :ref:`int<class_int>`)
- :ref:`int<class_int>` get_render_priority()
Sets the render priority for the sprite. Higher priority objects will be sorted in front of lower priority objects.
Note: This only applies if :ref:`alpha_cut<class_SpriteBase3D_property_alpha_cut>` is set to :ref:`ALPHA_CUT_DISABLED<class_SpriteBase3D_constant_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).
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` shaded = false
:ref:`🔗<class_SpriteBase3D_property_shaded>`
.. rst-class:: classref-property-setget
- |void| set_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`, enabled: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` get_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`) |const|
If true
, the :ref:`Light3D<class_Light3D>` in the :ref:`Environment<class_Environment>` has effects on the sprite.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`TextureFilter<enum_BaseMaterial3D_TextureFilter>` texture_filter = 3
:ref:`🔗<class_SpriteBase3D_property_texture_filter>`
.. rst-class:: classref-property-setget
- |void| set_texture_filter(value: :ref:`TextureFilter<enum_BaseMaterial3D_TextureFilter>`)
- :ref:`TextureFilter<enum_BaseMaterial3D_TextureFilter>` get_texture_filter()
Filter flags for the texture. See :ref:`TextureFilter<enum_BaseMaterial3D_TextureFilter>` for options.
Note: Linear filtering may cause artifacts around the edges, which are especially noticeable on opaque textures. To prevent this, use textures with transparent or identical colors around the edges.
.. rst-class:: classref-item-separator
.. rst-class:: classref-property
:ref:`bool<class_bool>` transparent = true
:ref:`🔗<class_SpriteBase3D_property_transparent>`
.. rst-class:: classref-property-setget
- |void| set_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`, enabled: :ref:`bool<class_bool>`)
- :ref:`bool<class_bool>` get_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`) |const|
If true
, the texture's transparency and the opacity are used to make those parts of the sprite invisible.
.. rst-class:: classref-section-separator
.. rst-class:: classref-descriptions-group
.. rst-class:: classref-method
:ref:`TriangleMesh<class_TriangleMesh>` generate_triangle_mesh() |const| :ref:`🔗<class_SpriteBase3D_method_generate_triangle_mesh>`
Returns a :ref:`TriangleMesh<class_TriangleMesh>` with the sprite's vertices following its current configuration (such as its :ref:`axis<class_SpriteBase3D_property_axis>` and :ref:`pixel_size<class_SpriteBase3D_property_pixel_size>`).
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
:ref:`bool<class_bool>` get_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`) |const| :ref:`🔗<class_SpriteBase3D_method_get_draw_flag>`
Returns the value of the specified flag.
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
:ref:`Rect2<class_Rect2>` get_item_rect() |const| :ref:`🔗<class_SpriteBase3D_method_get_item_rect>`
Returns the rectangle representing this sprite.
.. rst-class:: classref-item-separator
.. rst-class:: classref-method
|void| set_draw_flag(flag: :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>`, enabled: :ref:`bool<class_bool>`) :ref:`🔗<class_SpriteBase3D_method_set_draw_flag>`
If true
, the specified flag will be enabled. See :ref:`DrawFlags<enum_SpriteBase3D_DrawFlags>` for a list of flags.