Class ShaderMaterial
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A material that uses a custom Shader program to render visual items (canvas items, meshes, skies, fog), or to process particles. Compared to other materials, ShaderMaterial gives deeper control over the generated shader code. For more information, see the shaders documentation index below.
Multiple ShaderMaterials can use the same shader and configure different values for the shader uniforms.
Note: For performance reasons, the Changed signal is only emitted when the ResourceName changes. Only in editor, it is also emitted for Shader changes.
public class ShaderMaterial : Material, IDisposable
- Inheritance
-
ShaderMaterial
- Implements
- Inherited Members
Constructors
ShaderMaterial()
public ShaderMaterial()
Properties
Shader
The Shader program used to render this material.
public Shader Shader { get; set; }
Property Value
Methods
GetShaderParameter(StringName)
Returns the current value set for this material of a uniform in the shader.
public Variant GetShaderParameter(StringName param)
Parameters
param
StringName
Returns
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
SetShaderParameter(StringName, Variant)
Changes the value set for this material of a uniform in the shader.
Note:
param
is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).
Note: Changes to the shader uniform will be effective on all instances using this ShaderMaterial. To prevent this, use per-instance uniforms with SetInstanceShaderParameter(StringName, Variant) or duplicate the ShaderMaterial resource using Duplicate(bool). Per-instance uniforms allow for better shader reuse and are therefore faster, so they should be preferred over duplicating the ShaderMaterial when possible.
public void SetShaderParameter(StringName param, Variant value)
Parameters
param
StringNamevalue
Variant