Table of Contents

Class CanvasTexture

Namespace
Godot
Assembly
GodotSharp.dll

CanvasTexture is an alternative to ImageTexture for 2D rendering. It allows using normal maps and specular maps in any node that inherits from CanvasItem. CanvasTexture also allows overriding the texture's filter and repeat mode independently of the node's properties (or the project settings).

Note: CanvasTexture cannot be used in 3D. It will not display correctly when applied to any VisualInstance3D, such as Sprite3D or Decal. For physically-based materials in 3D, use BaseMaterial3D instead.

public class CanvasTexture : Texture2D, IDisposable
Inheritance
CanvasTexture
Implements
Inherited Members

Constructors

CanvasTexture()

public CanvasTexture()

Properties

DiffuseTexture

The diffuse (color) texture to use. This is the main texture you want to set in most cases.

public Texture2D DiffuseTexture { get; set; }

Property Value

Texture2D

NormalTexture

The normal map texture to use. Only has a visible effect if Light2Ds are affecting this CanvasTexture.

Note: Godot expects the normal map to use X+, Y+, and Z+ coordinates. See this page for a comparison of normal map coordinates expected by popular engines.

public Texture2D NormalTexture { get; set; }

Property Value

Texture2D

SpecularColor

The multiplier for specular reflection colors. The Light2D's color is also taken into account when determining the reflection color. Only has a visible effect if Light2Ds are affecting this CanvasTexture.

public Color SpecularColor { get; set; }

Property Value

Color

SpecularShininess

The specular exponent for Light2D specular reflections. Higher values result in a more glossy/"wet" look, with reflections becoming more localized and less visible overall. The default value of 1.0 disables specular reflections entirely. Only has a visible effect if Light2Ds are affecting this CanvasTexture.

public float SpecularShininess { get; set; }

Property Value

float

SpecularTexture

The specular map to use for Light2D specular reflections. This should be a grayscale or colored texture, with brighter areas resulting in a higher SpecularShininess value. Using a colored SpecularTexture allows controlling specular shininess on a per-channel basis. Only has a visible effect if Light2Ds are affecting this CanvasTexture.

public Texture2D SpecularTexture { get; set; }

Property Value

Texture2D

TextureFilter

The texture filtering mode to use when drawing this CanvasTexture.

public CanvasItem.TextureFilterEnum TextureFilter { get; set; }

Property Value

CanvasItem.TextureFilterEnum

TextureRepeat

The texture repeat mode to use when drawing this CanvasTexture.

public CanvasItem.TextureRepeatEnum TextureRepeat { get; set; }

Property Value

CanvasItem.TextureRepeatEnum

Methods

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool