Texture
Inherited By: AnimatedTexture, , CameraTexture, , ExternalTexture, , GradientTexture2D, , LargeTexture, , NoiseTexture, , StreamTexture,
Texture for 2D and 3D.
A texture works by registering an image in the video hardware, which then can be used in 3D models or 2D or GUI Control.
Textures are often created by loading them from a file. See .
is a base for other resources. It cannot be used directly.
Note: The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. Larger textures may fail to import.
Properties
Enumerations
enum Flags:
FLAGS_DEFAULT = 7 —- Default flags. , FLAG_REPEAT and are enabled.
FLAG_REPEAT = 2 —- Repeats the texture (instead of clamp to edge).
Note: Ignored when using an AtlasTexture as these don’t support repetition.
FLAG_FILTER = 4 —- Uses a magnifying filter, to enable smooth zooming in of the texture.
FLAG_ANISOTROPIC_FILTER = 8 —- Uses anisotropic mipmap filtering. Generates smaller versions of the same texture with different aspect ratios.
This results in better-looking textures when viewed from oblique angles.
FLAG_MIRRORED_REPEAT = 32 —- Repeats the texture with alternate sections mirrored.
Note: Ignored when using an as these don’t support repetition.
- FLAG_VIDEO_SURFACE = 2048 —- Texture is a video surface.
- flags
The texture’s Flags. are used to set various properties of the .
Method Descriptions
Draws the texture using a with the VisualServer API at the specified position
. Equivalent to with a rect at position
and the size of this .
- void draw_rect ( RID canvas_item, rect, bool tile, modulate=Color( 1, 1, 1, 1 ), bool transpose=false, normal_map=null ) const
Draws the texture using a CanvasItem with the API. Equivalent to VisualServer.canvas_item_add_texture_rect.
- void draw_rect_region ( canvas_item, Rect2 rect, src_rect, Color modulate=Color( 1, 1, 1, 1 ), transpose=false, Texture normal_map=null, clip_uv=true ) const
Draws a part of the texture using a CanvasItem with the API. Equivalent to VisualServer.canvas_item_add_texture_rect_region.
- get_data ( ) const
Returns an Image that is a copy of data from this Texture
. s can be accessed and manipulated directly.
- int get_height ( ) const
Returns the texture height.
- get_size ( ) const
Returns the texture size.
- int get_width ( ) const
Returns the texture width.
- has_alpha ( ) const