Table of Contents

Class Shader

Namespace
Godot
Assembly
GodotSharp.dll

A custom shader program implemented in the Godot shading language, saved with the .gdshader extension.

This class is used by a ShaderMaterial and allows you to write your own custom behavior for rendering visual items or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.

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

Constructors

Shader()

public Shader()

Properties

Code

Returns the shader's code as the user has written it, not the full generated code used internally.

public string Code { get; set; }

Property Value

string

Methods

GetDefaultTextureParameter(StringName, int)

Returns the texture that is set as default for the specified parameter.

Note: name must match the name of the uniform in the code exactly.

Note: If the sampler array is used use index to access the specified texture.

public Texture2D GetDefaultTextureParameter(StringName name, int index = 0)

Parameters

name StringName
index int

Returns

Texture2D

GetMode()

Returns the shader mode for the shader.

public Shader.Mode GetMode()

Returns

Shader.Mode

GetShaderUniformList(bool)

Get the list of shader uniforms that can be assigned to a ShaderMaterial, for use with SetShaderParameter(StringName, Variant) and GetShaderParameter(StringName). The parameters returned are contained in dictionaries in a similar format to the ones returned by GetPropertyList().

If argument getGroups is true, parameter grouping hints will be provided.

public Array GetShaderUniformList(bool getGroups = false)

Parameters

getGroups bool

Returns

Array

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

SetDefaultTextureParameter(StringName, Texture2D, int)

Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the ShaderMaterial.

Note: name must match the name of the uniform in the code exactly.

Note: If the sampler array is used use index to access the specified texture.

public void SetDefaultTextureParameter(StringName name, Texture2D texture, int index = 0)

Parameters

name StringName
texture Texture2D
index int