Skip to content
0.2.0-dev Download ZIP
38 lines ·2.5 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="ShaderMaterial" inherits="Material" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A material defined by a custom [Shader] program and the values of its shader parameters.
5 </brief_description>
6 <description>
7 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.
8 Multiple [ShaderMaterial]s can use the same shader and configure different values for the shader uniforms.
9 [b]Note:[/b] For performance reasons, the [signal Resource.changed] signal is only emitted when the [member Resource.resource_name] changes. Only in editor, it is also emitted for [member shader] changes.
10 </description>
11 <tutorials>
12 <link title="Shaders documentation index">$DOCS_URL/tutorials/shaders/index.html</link>
13 </tutorials>
14 <methods>
15 <method name="get_shader_parameter" qualifiers="const">
16 <return type="Variant" />
17 <param index="0" name="param" type="StringName" />
18 <description>
19 Returns the current value set for this material of a uniform in the shader.
20 </description>
21 </method>
22 <method name="set_shader_parameter">
23 <return type="void" />
24 <param index="0" name="param" type="StringName" />
25 <param index="1" name="value" type="Variant" />
26 <description>
27 Changes the value set for this material of a uniform in the shader.
28 [b]Note:[/b] [param param] is case-sensitive and must match the name of the uniform in the code exactly (not the capitalized name in the inspector).
29 [b]Note:[/b] Changes to the shader uniform will be effective on all instances using this [ShaderMaterial]. To prevent this, use per-instance uniforms with [method CanvasItem.set_instance_shader_parameter], [method GeometryInstance3D.set_instance_shader_parameter] or duplicate the [ShaderMaterial] resource using [method 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.
30 </description>
31 </method>
32 </methods>
33 <members>
34 <member name="shader" type="Shader" setter="set_shader" getter="get_shader">
35 The [Shader] program used to render this material.
36 </member>
37 </members>
38</class>