7dbc458bb4
This PR is a follow up to #64092, which fixed important issues but it was implemented in an overly complex and inefficient way (because it forced the default code path to always go through string operations). This cleans up all the shader parameter code. This fixes #54336. Also fixes #56219 because, as the new code never queries the RenderingServer on load, potential deadlocks are avoided. **NOTE**: materials saved between #62972 and #64092 will no longer work and will need to be resaved in an earlier version.
71 lines
3.6 KiB
XML
71 lines
3.6 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="Shader" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
|
<brief_description>
|
|
A custom shader program.
|
|
</brief_description>
|
|
<description>
|
|
This class allows you to define a custom shader program that can be used by a [ShaderMaterial]. Shaders allow you to write your own custom behavior for rendering objects or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
|
|
</description>
|
|
<tutorials>
|
|
<link title="Shaders documentation index">$DOCS_URL/tutorials/shaders/index.html</link>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="get_default_texture_parameter" qualifiers="const">
|
|
<return type="Texture2D" />
|
|
<param index="0" name="name" type="StringName" />
|
|
<param index="1" name="index" type="int" default="0" />
|
|
<description>
|
|
Returns the texture that is set as default for the specified parameter.
|
|
[b]Note:[/b] [param name] must match the name of the uniform in the code exactly.
|
|
[b]Note:[/b] If the sampler array is used use [param index] to access the specified texture.
|
|
</description>
|
|
</method>
|
|
<method name="get_mode" qualifiers="const">
|
|
<return type="int" enum="Shader.Mode" />
|
|
<description>
|
|
Returns the shader mode for the shader, either [constant MODE_CANVAS_ITEM], [constant MODE_SPATIAL] or [constant MODE_PARTICLES].
|
|
</description>
|
|
</method>
|
|
<method name="get_shader_uniform_list">
|
|
<return type="Array" />
|
|
<param index="0" name="get_groups" type="bool" default="false" />
|
|
<description>
|
|
Get the list of shader uniforms that can be assigned to a [ShaderMaterial], for use with [method ShaderMaterial.set_shader_parameter] and [method ShaderMaterial.get_shader_parameter]. The parameters returned are contained in dictionaries in a similar format to the ones returned by [method Object.get_property_list].
|
|
If argument [param get_groups] is true, parameter grouping hints will be provided.
|
|
</description>
|
|
</method>
|
|
<method name="set_default_texture_parameter">
|
|
<return type="void" />
|
|
<param index="0" name="name" type="StringName" />
|
|
<param index="1" name="texture" type="Texture2D" />
|
|
<param index="2" name="index" type="int" default="0" />
|
|
<description>
|
|
Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the [ShaderMaterial].
|
|
[b]Note:[/b] [param name] must match the name of the uniform in the code exactly.
|
|
[b]Note:[/b] If the sampler array is used use [param index] to access the specified texture.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="code" type="String" setter="set_code" getter="get_code" default="""">
|
|
Returns the shader's code as the user has written it, not the full generated code used internally.
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
<constant name="MODE_SPATIAL" value="0" enum="Mode">
|
|
Mode used to draw all 3D objects.
|
|
</constant>
|
|
<constant name="MODE_CANVAS_ITEM" value="1" enum="Mode">
|
|
Mode used to draw all 2D objects.
|
|
</constant>
|
|
<constant name="MODE_PARTICLES" value="2" enum="Mode">
|
|
Mode used to calculate particle information on a per-particle basis. Not used for drawing.
|
|
</constant>
|
|
<constant name="MODE_SKY" value="3" enum="Mode">
|
|
Mode used for drawing skies. Only works with shaders attached to [Sky] objects.
|
|
</constant>
|
|
<constant name="MODE_FOG" value="4" enum="Mode">
|
|
Mode used for setting the color and density of volumetric fog effect.
|
|
</constant>
|
|
</constants>
|
|
</class>
|