ShaderMaterial

继承: Material < Resource < RefCounted < Object

A material defined by a custom Shader program and the values of its shader parameters.

描述

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 ShaderMaterial s can use the same shader and configure different values for the shader uniforms.

Note: For performance reasons, the Resource.changed signal is only emitted when the Resource.resource_name changes. Only in editor, it is also emitted for shader changes.

属性

方法


属性说明

Shader shader

The Shader program used to render this material.


方法说明

Variant get_shader_parameter ( param: StringName ) const1

Returns the current value set for this material of a uniform in the shader.


void set_shader_parameter ( param: StringName, value: 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 GeometryInstance3D.set_instance_shader_parameter or duplicate the ShaderMaterial resource using Resource.duplicate. Per-instance uniforms allow for better shader reuse and are therefore faster, so they should be preferred over duplicating the ShaderMaterial when possible.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。