ShaderMaterial
Material with a Shader and its own parameter values.
References a Shader without automatically cloning it. Different ShaderMaterials can share one program with independent parameters; consumers of one shared ShaderMaterial share its values. The destination must match shader_type.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ShaderMaterialConstructor
public ShaderMaterial();Creates a material with no assigned Shader. Assign a suitable Shader and provide the material to the matching consumer. Constructing ShaderMaterial alone neither creates an arbitrary effect nor enables its required pass.
Properties1
ShaderProperty
public Shader Shader { get; set; }Shader used by the material. Several materials can reference one Shader while keeping separate regular uniforms. Meshes sharing one ShaderMaterial share its parameters; independent values require a separate material or an instance uniform.
Methods4
GetShaderShader
public Shader GetShader();Returns the assigned shared Shader resource, not a copy. The resource can be absent before assignment.
ShaderAssigned Shader, or null when none is assigned.
GetShaderParameterVariant
public Variant GetShaderParameter(StringName param);Reads a value explicitly stored in the ShaderMaterial. With no override, returns Nil even when shader code defines a default used by the rendered surface. Do not use the result as complete shader validation or proof that a misspelled name is supported.
| Name | Type | Default |
|---|---|---|
param | StringName | — |
paramExact case-sensitive parameter name. height_scale and Height_scale are different keys.
VariantStored Variant, or Nil with no override. In the verified example, height_scale initially returns Nil while its shader default of 0.9 creates visible relief.
SetShadervoid
public void SetShader(Shader shader);Assigns a Shader resource to the material without cloning it. Multiple materials can share shader code while keeping their own uniform values.
| Name | Type | Default |
|---|---|---|
shader | Shader | — |
shaderShader resource of a suitable type for the rendered object.
SetShaderParametervoid
public void SetShaderParameter(StringName param, Variant value);Writes a regular uniform on this material by its exact, case-sensitive name. Every user of the material sees the change. Nil removes the override and restores the shader default. Unknown names can be cached: reading a value back does not establish a declared uniform or a visible effect.
| Name | Type | Default |
|---|---|---|
param | StringName | — |
value | Variant | — |
paramRegular uniform name, such as height_scale. For an instance uniform, use GeometryInstance3D.SetInstanceShaderParameter. Check the name with Shader.GetShaderUniformList.
valueVariant containing a value compatible with the shader type; pass a Texture2D for sampler2D. default(Variant) is Nil and removes the override rather than assigning numeric zero.