Texture

    Inherited By: , AtlasTexture, , CurveTexture, , GradientTexture, , 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 Sprite or GUI .

    Textures are often created by loading them from a file. See @GDScript.load.

    is a base for other resources. It cannot be used directly.

    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_CONVERT_TO_LINEAR = 16 —- Converts the texture to the sRGB color space.
    • 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.

    The texture’s . Flags are used to set various properties of the .

    Method Descriptions


    • void draw_rect ( canvas_item, Rect2 rect, tile, Color modulate=Color( 1, 1, 1, 1 ), transpose=false, Texture normal_map=null ) const

    Draws the texture using a with the VisualServer API. Equivalent to .


    • void draw_rect_region ( RID canvas_item, rect, Rect2 src_rect, modulate=Color( 1, 1, 1, 1 ), bool transpose=false, normal_map=null, bool clip_uv=true ) const

    Draws a part of the texture using a with the VisualServer API. Equivalent to .


    • Image get_data ( ) const

    Returns an that is a copy of data from this Texture. Images can be accessed and manipulated directly.


    • get_height ( ) const

    Returns the texture height.


    Returns the texture size.


    • get_width ( ) const

    • bool has_alpha ( ) const

    Returns true if this has an alpha channel.