Table of Contents

Class Material

Namespace
Godot
Assembly
GodotSharp.dll

Material is a base resource used for coloring and shading geometry. All materials inherit from it and almost all VisualInstance3D derived nodes carry a Material. A few flags and parameters are shared between all material types and are configured here.

Importantly, you can inherit from Material to create your own custom material type in script or in GDExtension.

public class Material : Resource, IDisposable
Inheritance
Material
Implements
Derived
Inherited Members

Constructors

Material()

public Material()

Fields

RenderPriorityMax

Maximum value for the RenderPriority parameter.

public const long RenderPriorityMax = 127

Field Value

long

RenderPriorityMin

Minimum value for the RenderPriority parameter.

public const long RenderPriorityMin = -128

Field Value

long

Properties

NextPass

Sets the Material to be used for the next pass. This renders the object again using a different material.

Note: NextPass materials are not necessarily drawn immediately after the source Material. Draw order is determined by material properties, RenderPriority, and distance to camera.

Note: This only applies to StandardMaterial3Ds and ShaderMaterials with type "Spatial".

public Material NextPass { get; set; }

Property Value

Material

RenderPriority

Sets the render priority for objects in 3D scenes. Higher priority objects will be sorted in front of lower priority objects. In other words, all objects with RenderPriority1 will render before all objects with RenderPriority0.

Note: This only applies to StandardMaterial3Ds and ShaderMaterials with type "Spatial".

Note: This will not impact how transparent objects are sorted relative to opaque objects or how dynamic meshes will be sorted relative to other opaque meshes. This is because all transparent objects are drawn after all opaque objects and all dynamic opaque meshes are drawn before other opaque meshes.

public int RenderPriority { get; set; }

Property Value

int

Methods

CreatePlaceholder()

Creates a placeholder version of this resource (PlaceholderMaterial).

public Resource CreatePlaceholder()

Returns

Resource

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

InspectNativeShaderCode()

Only available when running in the editor. Opens a popup that visualizes the generated shader code, including all variants and internal shader code.

public void InspectNativeShaderCode()

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

_CanDoNextPass()

Only exposed for the purpose of overriding. You cannot call this function directly. Used internally to determine if NextPass should be shown in the editor or not.

public virtual bool _CanDoNextPass()

Returns

bool

_CanUseRenderPriority()

Only exposed for the purpose of overriding. You cannot call this function directly. Used internally to determine if RenderPriority should be shown in the editor or not.

public virtual bool _CanUseRenderPriority()

Returns

bool

_GetShaderMode()

Only exposed for the purpose of overriding. You cannot call this function directly. Used internally by various editor tools.

public virtual Shader.Mode _GetShaderMode()

Returns

Shader.Mode

_GetShaderRid()

Only exposed for the purpose of overriding. You cannot call this function directly. Used internally by various editor tools. Used to access the RID of the Material's Shader.

public virtual Rid _GetShaderRid()

Returns

Rid