mirror of
https://github.com/godotengine/godot
synced 2024-09-05 17:59:56 +00:00
Rename uniform
to parameter
across the engine
This commit is contained in:
parent
1c037c89d4
commit
8191b3c110
|
@ -9,9 +9,9 @@
|
|||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_instance_shader_uniform" qualifiers="const">
|
||||
<method name="get_instance_shader_parameter" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<param index="0" name="uniform" type="StringName" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
|
@ -22,9 +22,9 @@
|
|||
Overrides the bounding box of this node with a custom one. To remove it, set an [AABB] with all fields set to zero.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_instance_shader_uniform">
|
||||
<method name="set_instance_shader_parameter">
|
||||
<return type="void" />
|
||||
<param index="0" name="uniform" type="StringName" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<param index="1" name="value" type="Variant" />
|
||||
<description>
|
||||
</description>
|
||||
|
|
|
@ -1250,6 +1250,13 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_shader_parameter_list" qualifiers="const">
|
||||
<return type="Dictionary[]" />
|
||||
<param index="0" name="shader" type="RID" />
|
||||
<description>
|
||||
Returns the parameters of a shader.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_test_cube">
|
||||
<return type="RID" />
|
||||
<description>
|
||||
|
@ -1303,45 +1310,45 @@
|
|||
If [param half_resolution] is [code]true[/code], renders [VoxelGI] and SDFGI ([member Environment.sdfgi_enabled]) buffers at halved resolution (e.g. 960×540 when the viewport size is 1920×1080). This improves performance significantly when VoxelGI or SDFGI is enabled, at the cost of artifacts that may be visible on polygon edges. The loss in quality becomes less noticeable as the viewport resolution increases. [LightmapGI] rendering is not affected by this setting. See also [member ProjectSettings.rendering/global_illumination/gi/use_half_resolution].
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_add">
|
||||
<method name="global_shader_parameter_add">
|
||||
<return type="void" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<param index="1" name="type" type="int" enum="RenderingServer.GlobalShaderUniformType" />
|
||||
<param index="1" name="type" type="int" enum="RenderingServer.GlobalShaderParameterType" />
|
||||
<param index="2" name="default_value" type="Variant" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_get" qualifiers="const">
|
||||
<method name="global_shader_parameter_get" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_get_list" qualifiers="const">
|
||||
<method name="global_shader_parameter_get_list" qualifiers="const">
|
||||
<return type="PackedStringArray" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_get_type" qualifiers="const">
|
||||
<return type="int" enum="RenderingServer.GlobalShaderUniformType" />
|
||||
<method name="global_shader_parameter_get_type" qualifiers="const">
|
||||
<return type="int" enum="RenderingServer.GlobalShaderParameterType" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_remove">
|
||||
<method name="global_shader_parameter_remove">
|
||||
<return type="void" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_set">
|
||||
<method name="global_shader_parameter_set">
|
||||
<return type="void" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<param index="1" name="value" type="Variant" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="global_shader_uniform_set_override">
|
||||
<method name="global_shader_parameter_set_override">
|
||||
<return type="void" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<param index="1" name="value" type="Variant" />
|
||||
|
@ -1401,21 +1408,21 @@
|
|||
Once finished with your RID, you will want to free the RID using the RenderingServer's [method free_rid] static method.
|
||||
</description>
|
||||
</method>
|
||||
<method name="instance_geometry_get_shader_uniform" qualifiers="const">
|
||||
<method name="instance_geometry_get_shader_parameter" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<param index="0" name="instance" type="RID" />
|
||||
<param index="1" name="parameter" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="instance_geometry_get_shader_uniform_default_value" qualifiers="const">
|
||||
<method name="instance_geometry_get_shader_parameter_default_value" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<param index="0" name="instance" type="RID" />
|
||||
<param index="1" name="parameter" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="instance_geometry_get_shader_uniform_list" qualifiers="const">
|
||||
<method name="instance_geometry_get_shader_parameter_list" qualifiers="const">
|
||||
<return type="Dictionary[]" />
|
||||
<param index="0" name="instance" type="RID" />
|
||||
<description>
|
||||
|
@ -1470,7 +1477,7 @@
|
|||
Sets a material that will override the material for all surfaces on the mesh associated with this instance. Equivalent to [member GeometryInstance3D.material_override].
|
||||
</description>
|
||||
</method>
|
||||
<method name="instance_geometry_set_shader_uniform">
|
||||
<method name="instance_geometry_set_shader_parameter">
|
||||
<return type="void" />
|
||||
<param index="0" name="instance" type="RID" />
|
||||
<param index="1" name="parameter" type="StringName" />
|
||||
|
@ -2734,30 +2741,23 @@
|
|||
Returns a shader's code.
|
||||
</description>
|
||||
</method>
|
||||
<method name="shader_get_default_texture_param" qualifiers="const">
|
||||
<method name="shader_get_default_texture_parameter" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<param index="0" name="shader" type="RID" />
|
||||
<param index="1" name="param" type="StringName" />
|
||||
<param index="1" name="name" type="StringName" />
|
||||
<param index="2" name="index" type="int" default="0" />
|
||||
<description>
|
||||
Returns a default texture from a shader searched by name.
|
||||
[b]Note:[/b] If the sampler array is used use [param index] to access the specified texture.
|
||||
</description>
|
||||
</method>
|
||||
<method name="shader_get_param_default" qualifiers="const">
|
||||
<method name="shader_get_parameter_default" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<param index="0" name="shader" type="RID" />
|
||||
<param index="1" name="param" type="StringName" />
|
||||
<param index="1" name="name" type="StringName" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="shader_get_shader_uniform_list" qualifiers="const">
|
||||
<return type="Dictionary[]" />
|
||||
<param index="0" name="shader" type="RID" />
|
||||
<description>
|
||||
Returns the parameters of a shader.
|
||||
</description>
|
||||
</method>
|
||||
<method name="shader_set_code">
|
||||
<return type="void" />
|
||||
<param index="0" name="shader" type="RID" />
|
||||
|
@ -2765,10 +2765,10 @@
|
|||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="shader_set_default_texture_param">
|
||||
<method name="shader_set_default_texture_parameter">
|
||||
<return type="void" />
|
||||
<param index="0" name="shader" type="RID" />
|
||||
<param index="1" name="param" type="StringName" />
|
||||
<param index="1" name="name" type="StringName" />
|
||||
<param index="2" name="texture" type="RID" />
|
||||
<param index="3" name="index" type="int" default="0" />
|
||||
<description>
|
||||
|
@ -4576,63 +4576,63 @@
|
|||
<constant name="CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE" value="2" enum="CanvasOccluderPolygonCullMode">
|
||||
Culling of the canvas occluder is counterclockwise.
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_BOOL" value="0" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_BOOL" value="0" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_BVEC2" value="1" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_BVEC2" value="1" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_BVEC3" value="2" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_BVEC3" value="2" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_BVEC4" value="3" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_BVEC4" value="3" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_INT" value="4" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_INT" value="4" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_IVEC2" value="5" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_IVEC2" value="5" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_IVEC3" value="6" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_IVEC3" value="6" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_IVEC4" value="7" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_IVEC4" value="7" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_RECT2I" value="8" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_RECT2I" value="8" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_UINT" value="9" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_UINT" value="9" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_UVEC2" value="10" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_UVEC2" value="10" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_UVEC3" value="11" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_UVEC3" value="11" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_UVEC4" value="12" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_UVEC4" value="12" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_FLOAT" value="13" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_FLOAT" value="13" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_VEC2" value="14" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_VEC2" value="14" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_VEC3" value="15" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_VEC3" value="15" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_VEC4" value="16" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_VEC4" value="16" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_COLOR" value="17" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_COLOR" value="17" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_RECT2" value="18" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_RECT2" value="18" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_MAT2" value="19" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_MAT2" value="19" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_MAT3" value="20" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_MAT3" value="20" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_MAT4" value="21" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_MAT4" value="21" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_TRANSFORM_2D" value="22" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_TRANSFORM_2D" value="22" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_TRANSFORM" value="23" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_TRANSFORM" value="23" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLER2D" value="24" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLER2D" value="24" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLER2DARRAY" value="25" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLER2DARRAY" value="25" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLER3D" value="26" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLER3D" value="26" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLERCUBE" value="27" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_SAMPLERCUBE" value="27" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="GLOBAL_VAR_TYPE_MAX" value="28" enum="GlobalShaderUniformType">
|
||||
<constant name="GLOBAL_VAR_TYPE_MAX" value="28" enum="GlobalShaderParameterType">
|
||||
</constant>
|
||||
<constant name="RENDERING_INFO_TOTAL_OBJECTS_IN_FRAME" value="0" enum="RenderingInfo">
|
||||
</constant>
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
<link title="Shaders documentation index">$DOCS_URL/tutorials/shaders/index.html</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_default_texture_param" qualifiers="const">
|
||||
<method name="get_default_texture_parameter" qualifiers="const">
|
||||
<return type="Texture2D" />
|
||||
<param index="0" name="param" type="StringName" />
|
||||
<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 param] must match the name of the uniform in the code exactly.
|
||||
[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>
|
||||
|
@ -26,7 +26,7 @@
|
|||
Returns the shader mode for the shader, either [constant MODE_CANVAS_ITEM], [constant MODE_SPATIAL] or [constant MODE_PARTICLES].
|
||||
</description>
|
||||
</method>
|
||||
<method name="has_uniform" qualifiers="const">
|
||||
<method name="has_parameter" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<param index="0" name="name" type="StringName" />
|
||||
<description>
|
||||
|
@ -34,14 +34,14 @@
|
|||
[b]Note:[/b] [param name] must match the name of the uniform in the code exactly.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_default_texture_param">
|
||||
<method name="set_default_texture_parameter">
|
||||
<return type="void" />
|
||||
<param index="0" name="param" type="StringName" />
|
||||
<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 param] must match the name of the uniform in the code exactly.
|
||||
[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>
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
<link title="Shaders documentation index">$DOCS_URL/tutorials/shaders/index.html</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_shader_uniform" qualifiers="const">
|
||||
<method name="get_shader_parameter" qualifiers="const">
|
||||
<return type="Variant" />
|
||||
<param index="0" name="param" type="StringName" />
|
||||
<description>
|
||||
Returns the current value set for this material of a uniform in the shader.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_shader_uniform">
|
||||
<method name="set_shader_parameter">
|
||||
<return type="void" />
|
||||
<param index="0" name="param" type="StringName" />
|
||||
<param index="1" name="value" type="Variant" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeBooleanUniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeBooleanParameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A boolean uniform to be used within the visual shader graph.
|
||||
A boolean parameter to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform bool[/code] in the shader language.
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeColorUniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeColorParameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A [Color] uniform to be used within the visual shader graph.
|
||||
A [Color] parameter to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform vec4[/code] in the shader language.
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeCubemapUniform" inherits="VisualShaderNodeTextureUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeCubemapParameter" inherits="VisualShaderNodeTextureParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A [Cubemap] uniform node to be used within the visual shader graph.
|
||||
A [Cubemap] parameter node to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform samplerCube[/code] in the shader language. The output value can be used as port for [VisualShaderNodeCubemap].
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeFloatUniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeFloatParameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A scalar float uniform to be used within the visual shader graph.
|
||||
A scalar float parameter to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform float[/code] in the shader language.
|
||||
|
@ -15,7 +15,7 @@
|
|||
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
|
||||
Enables usage of the [member default_value].
|
||||
</member>
|
||||
<member name="hint" type="int" setter="set_hint" getter="get_hint" enum="VisualShaderNodeFloatUniform.Hint" default="0">
|
||||
<member name="hint" type="int" setter="set_hint" getter="get_hint" enum="VisualShaderNodeFloatParameter.Hint" default="0">
|
||||
A hint applied to the uniform, which controls the values it can take when set through the inspector.
|
||||
</member>
|
||||
<member name="max" type="float" setter="set_max" getter="get_max" default="1.0">
|
33
doc/classes/VisualShaderNodeIntParameter.xml
Normal file
33
doc/classes/VisualShaderNodeIntParameter.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeIntParameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="default_value" type="int" setter="set_default_value" getter="get_default_value" default="0">
|
||||
</member>
|
||||
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
|
||||
</member>
|
||||
<member name="hint" type="int" setter="set_hint" getter="get_hint" enum="VisualShaderNodeIntParameter.Hint" default="0">
|
||||
</member>
|
||||
<member name="max" type="int" setter="set_max" getter="get_max" default="100">
|
||||
</member>
|
||||
<member name="min" type="int" setter="set_min" getter="get_min" default="0">
|
||||
</member>
|
||||
<member name="step" type="int" setter="set_step" getter="get_step" default="1">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="HINT_NONE" value="0" enum="Hint">
|
||||
</constant>
|
||||
<constant name="HINT_RANGE" value="1" enum="Hint">
|
||||
</constant>
|
||||
<constant name="HINT_RANGE_STEP" value="2" enum="Hint">
|
||||
</constant>
|
||||
<constant name="HINT_MAX" value="3" enum="Hint">
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
|
@ -1,45 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeIntUniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A scalar integer uniform to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform int[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="default_value" type="int" setter="set_default_value" getter="get_default_value" default="0">
|
||||
A default value to be assigned within the shader.
|
||||
</member>
|
||||
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
|
||||
Enables usage of the [member default_value].
|
||||
</member>
|
||||
<member name="hint" type="int" setter="set_hint" getter="get_hint" enum="VisualShaderNodeIntUniform.Hint" default="0">
|
||||
A hint applied to the uniform, which controls the values it can take when set through the inspector.
|
||||
</member>
|
||||
<member name="max" type="int" setter="set_max" getter="get_max" default="100">
|
||||
Minimum value for range hints. Used if [member hint] is set to [constant HINT_RANGE] or [constant HINT_RANGE_STEP].
|
||||
</member>
|
||||
<member name="min" type="int" setter="set_min" getter="get_min" default="0">
|
||||
Maximum value for range hints. Used if [member hint] is set to [constant HINT_RANGE] or [constant HINT_RANGE_STEP].
|
||||
</member>
|
||||
<member name="step" type="int" setter="set_step" getter="get_step" default="1">
|
||||
Step (increment) value for the range hint with step. Used if [member hint] is set to [constant HINT_RANGE_STEP].
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="HINT_NONE" value="0" enum="Hint">
|
||||
No hint used.
|
||||
</constant>
|
||||
<constant name="HINT_RANGE" value="1" enum="Hint">
|
||||
A range hint for scalar value, which limits possible input values between [member min] and [member max]. Translated to [code]hint_range(min, max)[/code] in shader code.
|
||||
</constant>
|
||||
<constant name="HINT_RANGE_STEP" value="2" enum="Hint">
|
||||
A range hint for scalar value with step, which limits possible input values between [member min] and [member max], with a step (increment) of [member step]). Translated to [code]hint_range(min, max, step)[/code] in shader code.
|
||||
</constant>
|
||||
<constant name="HINT_MAX" value="3" enum="Hint">
|
||||
Represents the size of the [enum Hint] enum.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
29
doc/classes/VisualShaderNodeParameter.xml
Normal file
29
doc/classes/VisualShaderNodeParameter.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeParameter" inherits="VisualShaderNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A base type for the parameters within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
A parameter represents a variable in the shader which is set externally, i.e. from the [ShaderMaterial]. Parameters are exposed as properties in the [ShaderMaterial] and can be assigned from the inspector or from a script.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="parameter_name" type="String" setter="set_parameter_name" getter="get_parameter_name" default="""">
|
||||
Name of the parameter, by which it can be accessed through the [ShaderMaterial] properties.
|
||||
</member>
|
||||
<member name="qualifier" type="int" setter="set_qualifier" getter="get_qualifier" enum="VisualShaderNodeParameter.Qualifier" default="0">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="QUAL_NONE" value="0" enum="Qualifier">
|
||||
</constant>
|
||||
<constant name="QUAL_GLOBAL" value="1" enum="Qualifier">
|
||||
</constant>
|
||||
<constant name="QUAL_INSTANCE" value="2" enum="Qualifier">
|
||||
</constant>
|
||||
<constant name="QUAL_MAX" value="3" enum="Qualifier">
|
||||
Represents the size of the [enum Qualifier] enum.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
16
doc/classes/VisualShaderNodeParameterRef.xml
Normal file
16
doc/classes/VisualShaderNodeParameterRef.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeParameterRef" inherits="VisualShaderNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A reference to an existing [VisualShaderNodeParameter].
|
||||
</brief_description>
|
||||
<description>
|
||||
Creating a reference to a [VisualShaderNodeParameter] allows you to reuse this parameter in different shaders or shader stages easily.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="parameter_name" type="String" setter="set_parameter_name" getter="get_parameter_name" default=""[None]"">
|
||||
The name of the parameter which this reference points to.
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
9
doc/classes/VisualShaderNodeTexture2DArrayParameter.xml
Normal file
9
doc/classes/VisualShaderNodeTexture2DArrayParameter.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTexture2DArrayParameter" inherits="VisualShaderNodeTextureParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTexture2DArrayUniform" inherits="VisualShaderNodeTextureUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
11
doc/classes/VisualShaderNodeTexture2DParameter.xml
Normal file
11
doc/classes/VisualShaderNodeTexture2DParameter.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTexture2DParameter" inherits="VisualShaderNodeTextureParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Provides a 2D texture parameter within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform sampler2D[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
11
doc/classes/VisualShaderNodeTexture3DParameter.xml
Normal file
11
doc/classes/VisualShaderNodeTexture3DParameter.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTexture3DParameter" inherits="VisualShaderNodeTextureParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Provides a 3D texture parameter within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform sampler3D[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTexture3DUniform" inherits="VisualShaderNodeTextureUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Provides a 3D texture uniform within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform sampler3D[/code] in the shader language.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
</class>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTextureUniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeTextureParameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Performs a uniform texture lookup within the visual shader graph.
|
||||
</brief_description>
|
||||
|
@ -9,16 +9,16 @@
|
|||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="color_default" type="int" setter="set_color_default" getter="get_color_default" enum="VisualShaderNodeTextureUniform.ColorDefault" default="0">
|
||||
<member name="color_default" type="int" setter="set_color_default" getter="get_color_default" enum="VisualShaderNodeTextureParameter.ColorDefault" default="0">
|
||||
Sets the default color if no texture is assigned to the uniform.
|
||||
</member>
|
||||
<member name="texture_filter" type="int" setter="set_texture_filter" getter="get_texture_filter" enum="VisualShaderNodeTextureUniform.TextureFilter" default="0">
|
||||
<member name="texture_filter" type="int" setter="set_texture_filter" getter="get_texture_filter" enum="VisualShaderNodeTextureParameter.TextureFilter" default="0">
|
||||
Sets the texture filtering mode. See [enum TextureFilter] for options.
|
||||
</member>
|
||||
<member name="texture_repeat" type="int" setter="set_texture_repeat" getter="get_texture_repeat" enum="VisualShaderNodeTextureUniform.TextureRepeat" default="0">
|
||||
<member name="texture_repeat" type="int" setter="set_texture_repeat" getter="get_texture_repeat" enum="VisualShaderNodeTextureParameter.TextureRepeat" default="0">
|
||||
Sets the texture repeating mode. See [enum TextureRepeat] for options.
|
||||
</member>
|
||||
<member name="texture_type" type="int" setter="set_texture_type" getter="get_texture_type" enum="VisualShaderNodeTextureUniform.TextureType" default="0">
|
||||
<member name="texture_type" type="int" setter="set_texture_type" getter="get_texture_type" enum="VisualShaderNodeTextureParameter.TextureType" default="0">
|
||||
Defines the type of data provided by the source texture. See [enum TextureType] for options.
|
||||
</member>
|
||||
</members>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTextureUniformTriplanar" inherits="VisualShaderNodeTextureUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeTextureParameterTriplanar" inherits="VisualShaderNodeTextureParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Performs a uniform texture lookup with triplanar within the visual shader graph.
|
||||
</brief_description>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeTransformUniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeTransformParameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A [Transform3D] uniform for use within the visual shader graph.
|
||||
A [Transform3D] parameter for use within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform mat4[/code] in the shader language.
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeUniform" inherits="VisualShaderNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A base type for the uniforms within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
A uniform represents a variable in the shader which is set externally, i.e. from the [ShaderMaterial]. Uniforms are exposed as properties in the [ShaderMaterial] and can be assigned from the inspector or from a script.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="qualifier" type="int" setter="set_qualifier" getter="get_qualifier" enum="VisualShaderNodeUniform.Qualifier" default="0">
|
||||
</member>
|
||||
<member name="uniform_name" type="String" setter="set_uniform_name" getter="get_uniform_name" default="""">
|
||||
Name of the uniform, by which it can be accessed through the [ShaderMaterial] properties.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="QUAL_NONE" value="0" enum="Qualifier">
|
||||
</constant>
|
||||
<constant name="QUAL_GLOBAL" value="1" enum="Qualifier">
|
||||
</constant>
|
||||
<constant name="QUAL_INSTANCE" value="2" enum="Qualifier">
|
||||
</constant>
|
||||
<constant name="QUAL_MAX" value="3" enum="Qualifier">
|
||||
Represents the size of the [enum Qualifier] enum.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
|
@ -1,16 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeUniformRef" inherits="VisualShaderNode" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A reference to an existing [VisualShaderNodeUniform].
|
||||
</brief_description>
|
||||
<description>
|
||||
Creating a reference to a [VisualShaderNodeUniform] allows you to reuse this uniform in different shaders or shader stages easily.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="uniform_name" type="String" setter="set_uniform_name" getter="get_uniform_name" default=""[None]"">
|
||||
The name of the uniform which this reference points to.
|
||||
</member>
|
||||
</members>
|
||||
</class>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeVec2Uniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeVec2Parameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A [Vector2] uniform to be used within the visual shader graph.
|
||||
A [Vector2] parameter to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform vec2[/code] in the shader language.
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeVec3Uniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeVec3Parameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A [Vector3] uniform to be used within the visual shader graph.
|
||||
A [Vector3] parameter to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform vec3[/code] in the shader language.
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeVec4Constant" inherits="VisualShaderNodeConstant" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A 4D vector (represented as a [Quaternion]) constant to be used within the visual shader graph.
|
||||
A 4D vector constant to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
A constant 4D vector (represented as a [Quaternion]), which can be used as an input node.
|
||||
A constant 4D vector, which can be used as an input node.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VisualShaderNodeVec4Uniform" inherits="VisualShaderNodeUniform" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<class name="VisualShaderNodeVec4Parameter" inherits="VisualShaderNodeParameter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
A 4D vector (represented as a [Quaternion]) uniform to be used within the visual shader graph.
|
||||
A 4D vector parameter to be used within the visual shader graph.
|
||||
</brief_description>
|
||||
<description>
|
||||
Translated to [code]uniform vec4[/code] in the shader language.
|
||||
|
@ -9,7 +9,7 @@
|
|||
<tutorials>
|
||||
</tutorials>
|
||||
<members>
|
||||
<member name="default_value" type="Quaternion" setter="set_default_value" getter="get_default_value" default="Quaternion(0, 0, 0, 1)">
|
||||
<member name="default_value" type="Vector4" setter="set_default_value" getter="get_default_value" default="Vector4(0, 0, 0, 0)">
|
||||
A default value to be assigned within the shader.
|
||||
</member>
|
||||
<member name="default_value_enabled" type="bool" setter="set_default_value_enabled" getter="is_default_value_enabled" default="false">
|
|
@ -183,7 +183,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
|
|||
glBindBufferBase(GL_UNIFORM_BUFFER, BASE_UNIFORM_LOCATION, state.canvas_state_buffer);
|
||||
glBufferData(GL_UNIFORM_BUFFER, sizeof(StateBuffer), &state_buffer, GL_STREAM_DRAW);
|
||||
|
||||
GLuint global_buffer = material_storage->global_shader_uniforms_get_uniform_buffer();
|
||||
GLuint global_buffer = material_storage->global_shader_parameters_get_uniform_buffer();
|
||||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, GLOBAL_UNIFORM_LOCATION, global_buffer);
|
||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
|
|
|
@ -1736,7 +1736,7 @@ void RasterizerSceneGLES3::render_scene(RID p_render_buffers, const CameraData *
|
|||
// Fill Light lists here
|
||||
//////////
|
||||
|
||||
GLuint global_buffer = GLES3::MaterialStorage::get_singleton()->global_shader_uniforms_get_uniform_buffer();
|
||||
GLuint global_buffer = GLES3::MaterialStorage::get_singleton()->global_shader_parameters_get_uniform_buffer();
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, SCENE_GLOBALS_UNIFORM_LOCATION, global_buffer);
|
||||
|
||||
Color clear_color;
|
||||
|
|
|
@ -978,7 +978,7 @@ void MaterialData::update_uniform_buffer(const HashMap<StringName, ShaderLanguag
|
|||
if (gv) {
|
||||
index = gv->buffer_index;
|
||||
} else {
|
||||
WARN_PRINT("Shader uses global uniform '" + E.key + "', but it was removed at some point. Material will not display correctly.");
|
||||
WARN_PRINT("Shader uses global parameter '" + E.key + "', but it was removed at some point. Material will not display correctly.");
|
||||
}
|
||||
|
||||
uint32_t offset = p_uniform_offsets[E.value.order];
|
||||
|
@ -1095,7 +1095,7 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
GlobalShaderUniforms::Variable *v = material_storage->global_shader_uniforms.variables.getptr(uniform_name);
|
||||
if (v) {
|
||||
if (v->buffer_index >= 0) {
|
||||
WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!.");
|
||||
WARN_PRINT("Shader uses global parameter texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!.");
|
||||
|
||||
} else {
|
||||
HashMap<StringName, uint64_t>::Iterator E = used_global_textures.find(uniform_name);
|
||||
|
@ -1110,7 +1110,7 @@ void MaterialData::update_textures(const HashMap<StringName, Variant> &p_paramet
|
|||
}
|
||||
|
||||
} else {
|
||||
WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly.");
|
||||
WARN_PRINT("Shader uses global parameter texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly.");
|
||||
}
|
||||
} else {
|
||||
HashMap<StringName, Variant>::ConstIterator V = p_parameters.find(uniform_name);
|
||||
|
@ -1762,7 +1762,7 @@ int32_t MaterialStorage::_global_shader_uniform_allocate(uint32_t p_elements) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value) {
|
||||
void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value) {
|
||||
switch (p_type) {
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
|
||||
|
@ -2055,7 +2055,7 @@ void MaterialStorage::_global_shader_uniform_mark_buffer_dirty(int32_t p_index,
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) {
|
||||
ERR_FAIL_COND(global_shader_uniforms.variables.has(p_name));
|
||||
GlobalShaderUniforms::Variable gv;
|
||||
gv.type = p_type;
|
||||
|
@ -2093,7 +2093,7 @@ void MaterialStorage::global_shader_uniform_add(const StringName &p_name, RS::Gl
|
|||
global_shader_uniforms.variables[p_name] = gv;
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_remove(const StringName &p_name) {
|
||||
void MaterialStorage::global_shader_parameter_remove(const StringName &p_name) {
|
||||
if (!global_shader_uniforms.variables.has(p_name)) {
|
||||
return;
|
||||
}
|
||||
|
@ -2109,7 +2109,7 @@ void MaterialStorage::global_shader_uniform_remove(const StringName &p_name) {
|
|||
global_shader_uniforms.variables.erase(p_name);
|
||||
}
|
||||
|
||||
Vector<StringName> MaterialStorage::global_shader_uniform_get_list() const {
|
||||
Vector<StringName> MaterialStorage::global_shader_parameter_get_list() const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance.");
|
||||
}
|
||||
|
@ -2122,7 +2122,7 @@ Vector<StringName> MaterialStorage::global_shader_uniform_get_list() const {
|
|||
return names;
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_set(const StringName &p_name, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameter_set(const StringName &p_name, const Variant &p_value) {
|
||||
ERR_FAIL_COND(!global_shader_uniforms.variables.has(p_name));
|
||||
GlobalShaderUniforms::Variable &gv = global_shader_uniforms.variables[p_name];
|
||||
gv.value = p_value;
|
||||
|
@ -2143,7 +2143,7 @@ void MaterialStorage::global_shader_uniform_set(const StringName &p_name, const
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) {
|
||||
if (!global_shader_uniforms.variables.has(p_name)) {
|
||||
return; //variable may not exist
|
||||
}
|
||||
|
@ -2174,7 +2174,7 @@ void MaterialStorage::global_shader_uniform_set_override(const StringName &p_nam
|
|||
}
|
||||
}
|
||||
|
||||
Variant MaterialStorage::global_shader_uniform_get(const StringName &p_name) const {
|
||||
Variant MaterialStorage::global_shader_parameter_get(const StringName &p_name) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_V_MSG(Variant(), "This function should never be used outside the editor, it can severely damage performance.");
|
||||
}
|
||||
|
@ -2186,7 +2186,7 @@ Variant MaterialStorage::global_shader_uniform_get(const StringName &p_name) con
|
|||
return global_shader_uniforms.variables[p_name].value;
|
||||
}
|
||||
|
||||
RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type_internal(const StringName &p_name) const {
|
||||
RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type_internal(const StringName &p_name) const {
|
||||
if (!global_shader_uniforms.variables.has(p_name)) {
|
||||
return RS::GLOBAL_VAR_TYPE_MAX;
|
||||
}
|
||||
|
@ -2194,15 +2194,15 @@ RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type_inte
|
|||
return global_shader_uniforms.variables[p_name].type;
|
||||
}
|
||||
|
||||
RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type(const StringName &p_name) const {
|
||||
RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type(const StringName &p_name) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_V_MSG(RS::GLOBAL_VAR_TYPE_MAX, "This function should never be used outside the editor, it can severely damage performance.");
|
||||
}
|
||||
|
||||
return global_shader_uniform_get_type_internal(p_name);
|
||||
return global_shader_parameter_get_type_internal(p_name);
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures) {
|
||||
void MaterialStorage::global_shader_parameters_load_settings(bool p_load_textures) {
|
||||
List<PropertyInfo> settings;
|
||||
ProjectSettings::get_singleton()->get_property_list(&settings);
|
||||
|
||||
|
@ -2247,11 +2247,11 @@ void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures)
|
|||
"samplerCube",
|
||||
};
|
||||
|
||||
RS::GlobalShaderUniformType gvtype = RS::GLOBAL_VAR_TYPE_MAX;
|
||||
RS::GlobalShaderParameterType gvtype = RS::GLOBAL_VAR_TYPE_MAX;
|
||||
|
||||
for (int i = 0; i < RS::GLOBAL_VAR_TYPE_MAX; i++) {
|
||||
if (global_var_type_names[i] == type) {
|
||||
gvtype = RS::GlobalShaderUniformType(i);
|
||||
gvtype = RS::GlobalShaderParameterType(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2275,23 +2275,23 @@ void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures)
|
|||
|
||||
if (global_shader_uniforms.variables.has(name)) {
|
||||
//has it, update it
|
||||
global_shader_uniform_set(name, value);
|
||||
global_shader_parameter_set(name, value);
|
||||
} else {
|
||||
global_shader_uniform_add(name, gvtype, value);
|
||||
global_shader_parameter_add(name, gvtype, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_clear() {
|
||||
void MaterialStorage::global_shader_parameters_clear() {
|
||||
global_shader_uniforms.variables.clear();
|
||||
}
|
||||
|
||||
GLuint MaterialStorage::global_shader_uniforms_get_uniform_buffer() const {
|
||||
GLuint MaterialStorage::global_shader_parameters_get_uniform_buffer() const {
|
||||
return global_shader_uniforms.buffer;
|
||||
}
|
||||
|
||||
int32_t MaterialStorage::global_shader_uniforms_instance_allocate(RID p_instance) {
|
||||
int32_t MaterialStorage::global_shader_parameters_instance_allocate(RID p_instance) {
|
||||
ERR_FAIL_COND_V(global_shader_uniforms.instance_buffer_pos.has(p_instance), -1);
|
||||
int32_t pos = _global_shader_uniform_allocate(ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES);
|
||||
global_shader_uniforms.instance_buffer_pos[p_instance] = pos; //save anyway
|
||||
|
@ -2300,7 +2300,7 @@ int32_t MaterialStorage::global_shader_uniforms_instance_allocate(RID p_instance
|
|||
return pos;
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_instance_free(RID p_instance) {
|
||||
void MaterialStorage::global_shader_parameters_instance_free(RID p_instance) {
|
||||
ERR_FAIL_COND(!global_shader_uniforms.instance_buffer_pos.has(p_instance));
|
||||
int32_t pos = global_shader_uniforms.instance_buffer_pos[p_instance];
|
||||
if (pos >= 0) {
|
||||
|
@ -2309,7 +2309,7 @@ void MaterialStorage::global_shader_uniforms_instance_free(RID p_instance) {
|
|||
global_shader_uniforms.instance_buffer_pos.erase(p_instance);
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) {
|
||||
if (!global_shader_uniforms.instance_buffer_pos.has(p_instance)) {
|
||||
return; //just not allocated, ignore
|
||||
}
|
||||
|
@ -2498,7 +2498,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
|
|||
if (shader->data) {
|
||||
for (const KeyValue<StringName, HashMap<int, RID>> &E : shader->default_texture_parameter) {
|
||||
for (const KeyValue<int, RID> &E2 : E.value) {
|
||||
shader->data->set_default_texture_param(E.key, E2.value, E2.key);
|
||||
shader->data->set_default_texture_parameter(E.key, E2.value, E2.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2528,7 +2528,7 @@ String MaterialStorage::shader_get_code(RID p_shader) const {
|
|||
return shader->code;
|
||||
}
|
||||
|
||||
void MaterialStorage::shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
|
||||
void MaterialStorage::get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
|
||||
GLES3::Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
if (shader->data) {
|
||||
|
@ -2536,7 +2536,7 @@ void MaterialStorage::shader_get_shader_uniform_list(RID p_shader, List<Property
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) {
|
||||
void MaterialStorage::shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) {
|
||||
GLES3::Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
|
||||
|
@ -2555,7 +2555,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin
|
|||
}
|
||||
}
|
||||
if (shader->data) {
|
||||
shader->data->set_default_texture_param(p_name, p_texture, p_index);
|
||||
shader->data->set_default_texture_parameter(p_name, p_texture, p_index);
|
||||
}
|
||||
for (Material *E : shader->owners) {
|
||||
Material *material = E;
|
||||
|
@ -2563,7 +2563,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin
|
|||
}
|
||||
}
|
||||
|
||||
RID MaterialStorage::shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const {
|
||||
RID MaterialStorage::shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const {
|
||||
const GLES3::Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, RID());
|
||||
if (shader->default_texture_parameter.has(p_name) && shader->default_texture_parameter[p_name].has(p_index)) {
|
||||
|
@ -2573,7 +2573,7 @@ RID MaterialStorage::shader_get_default_texture_param(RID p_shader, const String
|
|||
return RID();
|
||||
}
|
||||
|
||||
Variant MaterialStorage::shader_get_param_default(RID p_shader, const StringName &p_param) const {
|
||||
Variant MaterialStorage::shader_get_parameter_default(RID p_shader, const StringName &p_param) const {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, Variant());
|
||||
if (shader->data) {
|
||||
|
@ -2693,7 +2693,7 @@ void MaterialStorage::material_set_param(RID p_material, const StringName &p_par
|
|||
}
|
||||
|
||||
if (material->shader && material->shader->data) { //shader is valid
|
||||
bool is_texture = material->shader->data->is_param_texture(p_param);
|
||||
bool is_texture = material->shader->data->is_parameter_texture(p_param);
|
||||
_material_queue_update(material, !is_texture, is_texture);
|
||||
} else {
|
||||
_material_queue_update(material, true, true);
|
||||
|
@ -2764,14 +2764,14 @@ bool MaterialStorage::material_casts_shadows(RID p_material) {
|
|||
return true; //by default everything casts shadows
|
||||
}
|
||||
|
||||
void MaterialStorage::material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) {
|
||||
void MaterialStorage::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) {
|
||||
GLES3::Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
if (material->shader && material->shader->data) {
|
||||
material->shader->data->get_instance_param_list(r_parameters);
|
||||
|
||||
if (material->next_pass.is_valid()) {
|
||||
material_get_instance_shader_uniforms(material->next_pass, r_parameters);
|
||||
material_get_instance_shader_parameters(material->next_pass, r_parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2867,7 +2867,7 @@ void CanvasShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void CanvasShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void CanvasShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -2938,7 +2938,7 @@ void CanvasShaderData::get_instance_param_list(List<RendererMaterialStorage::Ins
|
|||
}
|
||||
}
|
||||
|
||||
bool CanvasShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool CanvasShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3111,7 +3111,7 @@ void SkyShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void SkyShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void SkyShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -3180,7 +3180,7 @@ void SkyShaderData::get_instance_param_list(List<RendererMaterialStorage::Instan
|
|||
}
|
||||
}
|
||||
|
||||
bool SkyShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool SkyShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3435,7 +3435,7 @@ void SceneShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void SceneShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void SceneShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -3507,7 +3507,7 @@ void SceneShaderData::get_instance_param_list(List<RendererMaterialStorage::Inst
|
|||
}
|
||||
}
|
||||
|
||||
bool SceneShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool SceneShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -53,11 +53,11 @@ namespace GLES3 {
|
|||
|
||||
struct ShaderData {
|
||||
virtual void set_code(const String &p_Code) = 0;
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) = 0;
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) = 0;
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const = 0;
|
||||
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const = 0;
|
||||
virtual bool is_param_texture(const StringName &p_param) const = 0;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const = 0;
|
||||
virtual bool is_animated() const = 0;
|
||||
virtual bool casts_shadows() const = 0;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const = 0;
|
||||
|
@ -165,11 +165,11 @@ struct CanvasShaderData : public ShaderData {
|
|||
bool uses_time = false;
|
||||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
@ -216,10 +216,10 @@ struct SkyShaderData : public ShaderData {
|
|||
bool uses_light;
|
||||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
@ -337,11 +337,11 @@ struct SceneShaderData : public ShaderData {
|
|||
uint32_t index = 0;
|
||||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
@ -376,7 +376,7 @@ struct GlobalShaderUniforms {
|
|||
struct Variable {
|
||||
HashSet<RID> texture_materials; // materials using this
|
||||
|
||||
RS::GlobalShaderUniformType type;
|
||||
RS::GlobalShaderParameterType type;
|
||||
Variant value;
|
||||
Variant override;
|
||||
int32_t buffer_index; //for vectors
|
||||
|
@ -437,7 +437,7 @@ private:
|
|||
GlobalShaderUniforms global_shader_uniforms;
|
||||
|
||||
int32_t _global_shader_uniform_allocate(uint32_t p_elements);
|
||||
void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value);
|
||||
void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value);
|
||||
void _global_shader_uniform_mark_buffer_dirty(int32_t p_index, int32_t p_elements);
|
||||
|
||||
/* SHADER API */
|
||||
|
@ -515,24 +515,24 @@ public:
|
|||
|
||||
void _update_global_shader_uniforms();
|
||||
|
||||
virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) override;
|
||||
virtual void global_shader_uniform_remove(const StringName &p_name) override;
|
||||
virtual Vector<StringName> global_shader_uniform_get_list() const override;
|
||||
virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override;
|
||||
virtual void global_shader_parameter_remove(const StringName &p_name) override;
|
||||
virtual Vector<StringName> global_shader_parameter_get_list() const override;
|
||||
|
||||
virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual Variant global_shader_uniform_get(const StringName &p_name) const override;
|
||||
virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const override;
|
||||
RS::GlobalShaderUniformType global_shader_uniform_get_type_internal(const StringName &p_name) const;
|
||||
virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual Variant global_shader_parameter_get(const StringName &p_name) const override;
|
||||
virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override;
|
||||
RS::GlobalShaderParameterType global_shader_parameter_get_type_internal(const StringName &p_name) const;
|
||||
|
||||
virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) override;
|
||||
virtual void global_shader_uniforms_clear() override;
|
||||
virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override;
|
||||
virtual void global_shader_parameters_clear() override;
|
||||
|
||||
virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) override;
|
||||
virtual void global_shader_uniforms_instance_free(RID p_instance) override;
|
||||
virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) override;
|
||||
virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override;
|
||||
virtual void global_shader_parameters_instance_free(RID p_instance) override;
|
||||
virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) override;
|
||||
|
||||
GLuint global_shader_uniforms_get_uniform_buffer() const;
|
||||
GLuint global_shader_parameters_get_uniform_buffer() const;
|
||||
|
||||
/* SHADER API */
|
||||
|
||||
|
@ -548,11 +548,11 @@ public:
|
|||
virtual void shader_set_code(RID p_shader, const String &p_code) override;
|
||||
virtual void shader_set_path_hint(RID p_shader, const String &p_path) override;
|
||||
virtual String shader_get_code(RID p_shader) const override;
|
||||
virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const override;
|
||||
virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const override;
|
||||
|
||||
virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override;
|
||||
virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const override;
|
||||
virtual Variant shader_get_param_default(RID p_shader, const StringName &p_param) const override;
|
||||
virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override;
|
||||
virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override;
|
||||
virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_name) const override;
|
||||
|
||||
virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override;
|
||||
|
||||
|
@ -579,7 +579,7 @@ public:
|
|||
virtual bool material_is_animated(RID p_material) override;
|
||||
virtual bool material_casts_shadows(RID p_material) override;
|
||||
|
||||
virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) override;
|
||||
virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override;
|
||||
|
||||
virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) override;
|
||||
|
||||
|
|
|
@ -1070,7 +1070,7 @@ void EditorNode::_sources_changed(bool p_exist) {
|
|||
|
||||
// Reload the global shader variables, but this time
|
||||
// loading textures, as they are now properly imported.
|
||||
RenderingServer::get_singleton()->global_shader_uniforms_load_settings(true);
|
||||
RenderingServer::get_singleton()->global_shader_parameters_load_settings(true);
|
||||
|
||||
// Start preview thread now that it's safe.
|
||||
if (!singleton->cmdline_export_mode) {
|
||||
|
|
|
@ -1524,19 +1524,19 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
|
|||
// Render every past/future step with the capture shader.
|
||||
|
||||
RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid());
|
||||
onion.capture.material->set_shader_uniform("bkg_color", GLOBAL_GET("rendering/environment/defaults/default_clear_color"));
|
||||
onion.capture.material->set_shader_uniform("differences_only", onion.differences_only);
|
||||
onion.capture.material->set_shader_uniform("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID());
|
||||
onion.capture.material->set_shader_parameter("bkg_color", GLOBAL_GET("rendering/environment/defaults/default_clear_color"));
|
||||
onion.capture.material->set_shader_parameter("differences_only", onion.differences_only);
|
||||
onion.capture.material->set_shader_parameter("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID());
|
||||
|
||||
int step_off_a = onion.past ? -onion.steps : 0;
|
||||
int step_off_b = onion.future ? onion.steps : 0;
|
||||
int cidx = 0;
|
||||
onion.capture.material->set_shader_uniform("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color")));
|
||||
onion.capture.material->set_shader_parameter("dir_color", onion.force_white_modulate ? Color(1, 1, 1) : Color(EDITOR_GET("editors/animation/onion_layers_past_color")));
|
||||
for (int step_off = step_off_a; step_off <= step_off_b; step_off++) {
|
||||
if (step_off == 0) {
|
||||
// Skip present step and switch to the color of future.
|
||||
if (!onion.force_white_modulate) {
|
||||
onion.capture.material->set_shader_uniform("dir_color", EDITOR_GET("editors/animation/onion_layers_future_color"));
|
||||
onion.capture.material->set_shader_parameter("dir_color", EDITOR_GET("editors/animation/onion_layers_future_color"));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -339,17 +339,17 @@ Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
// Texture parameter has to be treated specially since StandardMaterial3D saved it
|
||||
// as RID but ShaderMaterial needs Texture itself
|
||||
Ref<Texture2D> texture = mat->get_texture_by_name(E.name);
|
||||
if (texture.is_valid()) {
|
||||
smat->set_shader_uniform(E.name, texture);
|
||||
smat->set_shader_parameter(E.name, texture);
|
||||
} else {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,17 +385,17 @@ Ref<Resource> ORMMaterial3DConversionPlugin::convert(const Ref<Resource> &p_reso
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
// Texture parameter has to be treated specially since ORMMaterial3D saved it
|
||||
// as RID but ShaderMaterial needs Texture itself
|
||||
Ref<Texture2D> texture = mat->get_texture_by_name(E.name);
|
||||
if (texture.is_valid()) {
|
||||
smat->set_shader_uniform(E.name, texture);
|
||||
smat->set_shader_parameter(E.name, texture);
|
||||
} else {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,11 +431,11 @@ Ref<Resource> ParticleProcessMaterialConversionPlugin::convert(const Ref<Resourc
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
@ -470,11 +470,11 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
@ -509,11 +509,11 @@ Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource>
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
@ -548,11 +548,11 @@ Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
@ -587,11 +587,11 @@ Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
@ -626,11 +626,11 @@ Ref<Resource> FogMaterialConversionPlugin::convert(const Ref<Resource> &p_resour
|
|||
smat->set_shader(shader);
|
||||
|
||||
List<PropertyInfo> params;
|
||||
RS::get_singleton()->shader_get_shader_uniform_list(mat->get_shader_rid(), ¶ms);
|
||||
RS::get_singleton()->get_shader_parameter_list(mat->get_shader_rid(), ¶ms);
|
||||
|
||||
for (const PropertyInfo &E : params) {
|
||||
Variant value = RS::get_singleton()->material_get_param(mat->get_rid(), E.name);
|
||||
smat->set_shader_uniform(E.name, value);
|
||||
smat->set_shader_parameter(E.name, value);
|
||||
}
|
||||
|
||||
smat->set_render_priority(mat->get_render_priority());
|
||||
|
|
|
@ -6408,7 +6408,7 @@ void fragment() {
|
|||
Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial);
|
||||
rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX);
|
||||
rotate_mat->set_shader(rotate_shader);
|
||||
rotate_mat->set_shader_uniform("albedo", col);
|
||||
rotate_mat->set_shader_parameter("albedo", col);
|
||||
rotate_gizmo_color[i] = rotate_mat;
|
||||
|
||||
Array arrays = surftool->commit_to_arrays();
|
||||
|
@ -6416,7 +6416,7 @@ void fragment() {
|
|||
rotate_gizmo[i]->surface_set_material(0, rotate_mat);
|
||||
|
||||
Ref<ShaderMaterial> rotate_mat_hl = rotate_mat->duplicate();
|
||||
rotate_mat_hl->set_shader_uniform("albedo", albedo);
|
||||
rotate_mat_hl->set_shader_parameter("albedo", albedo);
|
||||
rotate_gizmo_color_hl[i] = rotate_mat_hl;
|
||||
|
||||
if (i == 2) { // Rotation white outline
|
||||
|
@ -6457,7 +6457,7 @@ void fragment() {
|
|||
)");
|
||||
|
||||
border_mat->set_shader(border_shader);
|
||||
border_mat->set_shader_uniform("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0));
|
||||
border_mat->set_shader_parameter("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0));
|
||||
|
||||
rotate_gizmo[3] = Ref<ArrayMesh>(memnew(ArrayMesh));
|
||||
rotate_gizmo[3]->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
|
||||
|
@ -6710,8 +6710,8 @@ void Node3DEditor::_init_grid() {
|
|||
fade_size = CLAMP(fade_size, min_fade_size, max_fade_size);
|
||||
|
||||
real_t grid_fade_size = (grid_size - primary_grid_steps) * fade_size;
|
||||
grid_mat[c]->set_shader_uniform("grid_size", grid_fade_size);
|
||||
grid_mat[c]->set_shader_uniform("orthogonal", orthogonal);
|
||||
grid_mat[c]->set_shader_parameter("grid_size", grid_fade_size);
|
||||
grid_mat[c]->set_shader_parameter("orthogonal", orthogonal);
|
||||
|
||||
// Cache these so we don't have to re-access memory.
|
||||
Vector<Vector3> &ref_grid = grid_points[c];
|
||||
|
@ -7567,9 +7567,9 @@ void Node3DEditor::_sun_direction_draw() {
|
|||
sun_direction->draw_rect(Rect2(Vector2(), sun_direction->get_size()), Color(1, 1, 1, 1));
|
||||
Vector3 z_axis = preview_sun->get_transform().basis.get_column(Vector3::AXIS_Z);
|
||||
z_axis = get_editor_viewport(0)->camera->get_camera_transform().basis.xform_inv(z_axis);
|
||||
sun_direction_material->set_shader_uniform("sun_direction", Vector3(z_axis.x, -z_axis.y, z_axis.z));
|
||||
sun_direction_material->set_shader_parameter("sun_direction", Vector3(z_axis.x, -z_axis.y, z_axis.z));
|
||||
Color color = sun_color->get_pick_color() * sun_energy->get_value();
|
||||
sun_direction_material->set_shader_uniform("sun_color", Vector3(color.r, color.g, color.b));
|
||||
sun_direction_material->set_shader_parameter("sun_color", Vector3(color.r, color.g, color.b));
|
||||
}
|
||||
|
||||
void Node3DEditor::_preview_settings_changed() {
|
||||
|
@ -8170,8 +8170,8 @@ void fragment() {
|
|||
)");
|
||||
sun_direction_material.instantiate();
|
||||
sun_direction_material->set_shader(sun_direction_shader);
|
||||
sun_direction_material->set_shader_uniform("sun_direction", Vector3(0, 0, 1));
|
||||
sun_direction_material->set_shader_uniform("sun_color", Vector3(1, 1, 1));
|
||||
sun_direction_material->set_shader_parameter("sun_direction", Vector3(0, 0, 1));
|
||||
sun_direction_material->set_shader_parameter("sun_color", Vector3(1, 1, 1));
|
||||
sun_direction->set_material(sun_direction_material);
|
||||
|
||||
HBoxContainer *sun_angle_hbox = memnew(HBoxContainer);
|
||||
|
|
|
@ -355,7 +355,7 @@ void ShaderTextEditor::_check_shader_mode() {
|
|||
}
|
||||
|
||||
static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) {
|
||||
RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_variable);
|
||||
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
|
||||
return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
|
||||
}
|
||||
|
||||
|
|
|
@ -919,8 +919,8 @@ void fragment() {
|
|||
)");
|
||||
handle_material->set_shader(handle_shader);
|
||||
Ref<Texture2D> handle = EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("EditorBoneHandle"), SNAME("EditorIcons"));
|
||||
handle_material->set_shader_uniform("point_size", handle->get_width());
|
||||
handle_material->set_shader_uniform("texture_albedo", handle);
|
||||
handle_material->set_shader_parameter("point_size", handle->get_width());
|
||||
handle_material->set_shader_parameter("texture_albedo", handle);
|
||||
|
||||
handles_mesh_instance = memnew(MeshInstance3D);
|
||||
handles_mesh_instance->set_cast_shadows_setting(GeometryInstance3D::SHADOW_CASTING_SETTING_OFF);
|
||||
|
|
|
@ -57,8 +57,8 @@ void Texture3DEditor::_texture_changed() {
|
|||
}
|
||||
|
||||
void Texture3DEditor::_update_material() {
|
||||
material->set_shader_uniform("layer", (layer->get_value() + 0.5) / texture->get_depth());
|
||||
material->set_shader_uniform("tex", texture->get_rid());
|
||||
material->set_shader_parameter("layer", (layer->get_value() + 0.5) / texture->get_depth());
|
||||
material->set_shader_parameter("tex", texture->get_rid());
|
||||
|
||||
String format = Image::get_format_name(texture->get_format());
|
||||
|
||||
|
|
|
@ -68,9 +68,9 @@ void TextureLayeredEditor::_texture_changed() {
|
|||
}
|
||||
|
||||
void TextureLayeredEditor::_update_material() {
|
||||
materials[0]->set_shader_uniform("layer", layer->get_value());
|
||||
materials[2]->set_shader_uniform("layer", layer->get_value());
|
||||
materials[texture->get_layered_type()]->set_shader_uniform("tex", texture->get_rid());
|
||||
materials[0]->set_shader_parameter("layer", layer->get_value());
|
||||
materials[2]->set_shader_parameter("layer", layer->get_value());
|
||||
materials[texture->get_layered_type()]->set_shader_parameter("tex", texture->get_rid());
|
||||
|
||||
Vector3 v(1, 1, 1);
|
||||
v.normalize();
|
||||
|
@ -79,10 +79,10 @@ void TextureLayeredEditor::_update_material() {
|
|||
b.rotate(Vector3(1, 0, 0), x_rot);
|
||||
b.rotate(Vector3(0, 1, 0), y_rot);
|
||||
|
||||
materials[1]->set_shader_uniform("normal", v);
|
||||
materials[1]->set_shader_uniform("rot", b);
|
||||
materials[2]->set_shader_uniform("normal", v);
|
||||
materials[2]->set_shader_uniform("rot", b);
|
||||
materials[1]->set_shader_parameter("normal", v);
|
||||
materials[1]->set_shader_parameter("rot", b);
|
||||
materials[2]->set_shader_parameter("normal", v);
|
||||
materials[2]->set_shader_parameter("rot", b);
|
||||
|
||||
String format = Image::get_format_name(texture->get_format());
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void VisualShaderGraphPlugin::_bind_methods() {
|
|||
ClassDB::bind_method("update_node", &VisualShaderGraphPlugin::update_node);
|
||||
ClassDB::bind_method("update_node_deferred", &VisualShaderGraphPlugin::update_node_deferred);
|
||||
ClassDB::bind_method("set_input_port_default_value", &VisualShaderGraphPlugin::set_input_port_default_value);
|
||||
ClassDB::bind_method("set_uniform_name", &VisualShaderGraphPlugin::set_uniform_name);
|
||||
ClassDB::bind_method("set_parameter_name", &VisualShaderGraphPlugin::set_parameter_name);
|
||||
ClassDB::bind_method("set_expression", &VisualShaderGraphPlugin::set_expression);
|
||||
ClassDB::bind_method("update_curve", &VisualShaderGraphPlugin::update_curve);
|
||||
ClassDB::bind_method("update_curve_xyz", &VisualShaderGraphPlugin::update_curve_xyz);
|
||||
|
@ -223,9 +223,9 @@ void VisualShaderGraphPlugin::set_input_port_default_value(VisualShader::Type p_
|
|||
}
|
||||
}
|
||||
|
||||
void VisualShaderGraphPlugin::set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name) {
|
||||
if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].uniform_name != nullptr) {
|
||||
links[p_node_id].uniform_name->set_text(p_name);
|
||||
void VisualShaderGraphPlugin::set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name) {
|
||||
if (visual_shader->get_shader_type() == p_type && links.has(p_node_id) && links[p_node_id].parameter_name != nullptr) {
|
||||
links[p_node_id].parameter_name->set_text(p_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,9 +290,9 @@ void VisualShaderGraphPlugin::register_curve_editor(int p_node_id, int p_index,
|
|||
links[p_node_id].curve_editors[p_index] = p_curve_editor;
|
||||
}
|
||||
|
||||
void VisualShaderGraphPlugin::update_uniform_refs() {
|
||||
void VisualShaderGraphPlugin::update_parameter_refs() {
|
||||
for (KeyValue<int, Link> &E : links) {
|
||||
VisualShaderNodeUniformRef *ref = Object::cast_to<VisualShaderNodeUniformRef>(E.value.visual_node);
|
||||
VisualShaderNodeParameterRef *ref = Object::cast_to<VisualShaderNodeParameterRef>(E.value.visual_node);
|
||||
if (ref) {
|
||||
remove_node(E.value.type, E.key);
|
||||
add_node(E.value.type, E.key);
|
||||
|
@ -334,8 +334,8 @@ void VisualShaderGraphPlugin::register_output_port(int p_node_id, int p_port, Te
|
|||
links[p_node_id].output_ports.insert(p_port, { p_button });
|
||||
}
|
||||
|
||||
void VisualShaderGraphPlugin::register_uniform_name(int p_node_id, LineEdit *p_uniform_name) {
|
||||
links[p_node_id].uniform_name = p_uniform_name;
|
||||
void VisualShaderGraphPlugin::register_parameter_name(int p_node_id, LineEdit *p_parameter_name) {
|
||||
links[p_node_id].parameter_name = p_parameter_name;
|
||||
}
|
||||
|
||||
void VisualShaderGraphPlugin::update_theme() {
|
||||
|
@ -466,29 +466,29 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
|
|||
node->set_custom_minimum_size(Size2(200 * EDSCALE, 0));
|
||||
}
|
||||
|
||||
Ref<VisualShaderNodeUniformRef> uniform_ref = vsnode;
|
||||
if (uniform_ref.is_valid()) {
|
||||
uniform_ref->set_shader_rid(visual_shader->get_rid());
|
||||
uniform_ref->update_uniform_type();
|
||||
Ref<VisualShaderNodeParameterRef> parameter_ref = vsnode;
|
||||
if (parameter_ref.is_valid()) {
|
||||
parameter_ref->set_shader_rid(visual_shader->get_rid());
|
||||
parameter_ref->update_parameter_type();
|
||||
}
|
||||
|
||||
Ref<VisualShaderNodeUniform> uniform = vsnode;
|
||||
Ref<VisualShaderNodeParameter> parameter = vsnode;
|
||||
HBoxContainer *hb = nullptr;
|
||||
|
||||
if (uniform.is_valid()) {
|
||||
LineEdit *uniform_name = memnew(LineEdit);
|
||||
register_uniform_name(p_id, uniform_name);
|
||||
uniform_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
uniform_name->set_text(uniform->get_uniform_name());
|
||||
uniform_name->connect("text_submitted", callable_mp(editor, &VisualShaderEditor::_uniform_line_edit_changed).bind(p_id));
|
||||
uniform_name->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_uniform_line_edit_focus_out).bind(uniform_name, p_id));
|
||||
if (parameter.is_valid()) {
|
||||
LineEdit *parameter_name = memnew(LineEdit);
|
||||
register_parameter_name(p_id, parameter_name);
|
||||
parameter_name->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
parameter_name->set_text(parameter->get_parameter_name());
|
||||
parameter_name->connect("text_submitted", callable_mp(editor, &VisualShaderEditor::_parameter_line_edit_changed).bind(p_id));
|
||||
parameter_name->connect("focus_exited", callable_mp(editor, &VisualShaderEditor::_parameter_line_edit_focus_out).bind(parameter_name, p_id));
|
||||
|
||||
if (vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
|
||||
hb = memnew(HBoxContainer);
|
||||
hb->add_child(uniform_name);
|
||||
hb->add_child(parameter_name);
|
||||
node->add_child(hb);
|
||||
} else {
|
||||
node->add_child(uniform_name);
|
||||
node->add_child(parameter_name);
|
||||
}
|
||||
port_offset++;
|
||||
}
|
||||
|
@ -1409,13 +1409,13 @@ void VisualShaderEditor::_update_options_menu() {
|
|||
}
|
||||
}
|
||||
|
||||
Ref<VisualShaderNodeUniformRef> uniform_ref = Object::cast_to<VisualShaderNodeUniformRef>(vsn.ptr());
|
||||
if (uniform_ref.is_valid()) {
|
||||
Ref<VisualShaderNodeParameterRef> parameter_ref = Object::cast_to<VisualShaderNodeParameterRef>(vsn.ptr());
|
||||
if (parameter_ref.is_valid()) {
|
||||
check_result = -1;
|
||||
|
||||
if (members_input_port_type != VisualShaderNode::PORT_TYPE_MAX) {
|
||||
for (int j = 0; j < uniform_ref->get_uniforms_count(); j++) {
|
||||
if (visual_shader->is_port_types_compatible(uniform_ref->get_port_type_by_index(j), members_input_port_type)) {
|
||||
for (int j = 0; j < parameter_ref->get_parameters_count(); j++) {
|
||||
if (visual_shader->is_port_types_compatible(parameter_ref->get_port_type_by_index(j), members_input_port_type)) {
|
||||
check_result = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -1612,66 +1612,66 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
|
|||
node->add_theme_color_override("resizer_color", c);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_uniforms(bool p_update_refs) {
|
||||
VisualShaderNodeUniformRef::clear_uniforms(visual_shader->get_rid());
|
||||
void VisualShaderEditor::_update_parameters(bool p_update_refs) {
|
||||
VisualShaderNodeParameterRef::clear_parameters(visual_shader->get_rid());
|
||||
|
||||
for (int t = 0; t < VisualShader::TYPE_MAX; t++) {
|
||||
Vector<int> tnodes = visual_shader->get_node_list((VisualShader::Type)t);
|
||||
for (int i = 0; i < tnodes.size(); i++) {
|
||||
Ref<VisualShaderNode> vsnode = visual_shader->get_node((VisualShader::Type)t, tnodes[i]);
|
||||
Ref<VisualShaderNodeUniform> uniform = vsnode;
|
||||
Ref<VisualShaderNodeParameter> parameter = vsnode;
|
||||
|
||||
if (uniform.is_valid()) {
|
||||
Ref<VisualShaderNodeFloatUniform> float_uniform = vsnode;
|
||||
Ref<VisualShaderNodeIntUniform> int_uniform = vsnode;
|
||||
Ref<VisualShaderNodeVec2Uniform> vec2_uniform = vsnode;
|
||||
Ref<VisualShaderNodeVec3Uniform> vec3_uniform = vsnode;
|
||||
Ref<VisualShaderNodeVec4Uniform> vec4_uniform = vsnode;
|
||||
Ref<VisualShaderNodeColorUniform> color_uniform = vsnode;
|
||||
Ref<VisualShaderNodeBooleanUniform> bool_uniform = vsnode;
|
||||
Ref<VisualShaderNodeTransformUniform> transform_uniform = vsnode;
|
||||
if (parameter.is_valid()) {
|
||||
Ref<VisualShaderNodeFloatParameter> float_parameter = vsnode;
|
||||
Ref<VisualShaderNodeIntParameter> int_parameter = vsnode;
|
||||
Ref<VisualShaderNodeVec2Parameter> vec2_parameter = vsnode;
|
||||
Ref<VisualShaderNodeVec3Parameter> vec3_parameter = vsnode;
|
||||
Ref<VisualShaderNodeVec4Parameter> vec4_parameter = vsnode;
|
||||
Ref<VisualShaderNodeColorParameter> color_parameter = vsnode;
|
||||
Ref<VisualShaderNodeBooleanParameter> boolean_parameter = vsnode;
|
||||
Ref<VisualShaderNodeTransformParameter> transform_parameter = vsnode;
|
||||
|
||||
VisualShaderNodeUniformRef::UniformType uniform_type;
|
||||
if (float_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_FLOAT;
|
||||
} else if (int_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_INT;
|
||||
} else if (bool_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_BOOLEAN;
|
||||
} else if (vec2_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_VECTOR2;
|
||||
} else if (vec3_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_VECTOR3;
|
||||
} else if (vec4_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_VECTOR4;
|
||||
} else if (transform_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_TRANSFORM;
|
||||
} else if (color_uniform.is_valid()) {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_COLOR;
|
||||
VisualShaderNodeParameterRef::ParameterType parameter_type;
|
||||
if (float_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_FLOAT;
|
||||
} else if (int_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_INT;
|
||||
} else if (boolean_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_BOOLEAN;
|
||||
} else if (vec2_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_VECTOR2;
|
||||
} else if (vec3_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_VECTOR3;
|
||||
} else if (vec4_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_VECTOR4;
|
||||
} else if (transform_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_TRANSFORM;
|
||||
} else if (color_parameter.is_valid()) {
|
||||
parameter_type = VisualShaderNodeParameterRef::PARAMETER_TYPE_COLOR;
|
||||
} else {
|
||||
uniform_type = VisualShaderNodeUniformRef::UniformType::UNIFORM_TYPE_SAMPLER;
|
||||
parameter_type = VisualShaderNodeParameterRef::UNIFORM_TYPE_SAMPLER;
|
||||
}
|
||||
VisualShaderNodeUniformRef::add_uniform(visual_shader->get_rid(), uniform->get_uniform_name(), uniform_type);
|
||||
VisualShaderNodeParameterRef::add_parameter(visual_shader->get_rid(), parameter->get_parameter_name(), parameter_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p_update_refs) {
|
||||
graph_plugin->update_uniform_refs();
|
||||
graph_plugin->update_parameter_refs();
|
||||
}
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_uniform_refs(HashSet<String> &p_deleted_names) {
|
||||
void VisualShaderEditor::_update_parameter_refs(HashSet<String> &p_deleted_names) {
|
||||
for (int i = 0; i < VisualShader::TYPE_MAX; i++) {
|
||||
VisualShader::Type type = VisualShader::Type(i);
|
||||
|
||||
Vector<int> nodes = visual_shader->get_node_list(type);
|
||||
for (int j = 0; j < nodes.size(); j++) {
|
||||
if (j > 0) {
|
||||
Ref<VisualShaderNodeUniformRef> ref = visual_shader->get_node(type, nodes[j]);
|
||||
Ref<VisualShaderNodeParameterRef> ref = visual_shader->get_node(type, nodes[j]);
|
||||
if (ref.is_valid()) {
|
||||
if (p_deleted_names.has(ref->get_uniform_name())) {
|
||||
undo_redo->add_do_method(ref.ptr(), "set_uniform_name", "[None]");
|
||||
undo_redo->add_undo_method(ref.ptr(), "set_uniform_name", ref->get_uniform_name());
|
||||
if (p_deleted_names.has(ref->get_parameter_name())) {
|
||||
undo_redo->add_do_method(ref.ptr(), "set_parameter_name", "[None]");
|
||||
undo_redo->add_undo_method(ref.ptr(), "set_parameter_name", ref->get_parameter_name());
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "update_node", VisualShader::Type(i), nodes[j]);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", VisualShader::Type(i), nodes[j]);
|
||||
}
|
||||
|
@ -1711,7 +1711,7 @@ void VisualShaderEditor::_update_graph() {
|
|||
|
||||
Vector<int> nodes = visual_shader->get_node_list(type);
|
||||
|
||||
_update_uniforms(false);
|
||||
_update_parameters(false);
|
||||
_update_varyings();
|
||||
|
||||
graph_plugin->clear_links();
|
||||
|
@ -2257,38 +2257,38 @@ void VisualShaderEditor::_comment_desc_popup_hide() {
|
|||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_uniform_line_edit_changed(const String &p_text, int p_node_id) {
|
||||
void VisualShaderEditor::_parameter_line_edit_changed(const String &p_text, int p_node_id) {
|
||||
VisualShader::Type type = get_current_shader_type();
|
||||
|
||||
Ref<VisualShaderNodeUniform> node = visual_shader->get_node(type, p_node_id);
|
||||
Ref<VisualShaderNodeParameter> node = visual_shader->get_node(type, p_node_id);
|
||||
ERR_FAIL_COND(!node.is_valid());
|
||||
|
||||
String validated_name = visual_shader->validate_uniform_name(p_text, node);
|
||||
String validated_name = visual_shader->validate_parameter_name(p_text, node);
|
||||
|
||||
if (validated_name == node->get_uniform_name()) {
|
||||
if (validated_name == node->get_parameter_name()) {
|
||||
return;
|
||||
}
|
||||
|
||||
undo_redo->create_action(TTR("Set Uniform Name"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_uniform_name", validated_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_uniform_name", node->get_uniform_name());
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "set_uniform_name", type, p_node_id, validated_name);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "set_uniform_name", type, p_node_id, node->get_uniform_name());
|
||||
undo_redo->create_action(TTR("Set Parameter Name"));
|
||||
undo_redo->add_do_method(node.ptr(), "set_parameter_name", validated_name);
|
||||
undo_redo->add_undo_method(node.ptr(), "set_parameter_name", node->get_parameter_name());
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "set_parameter_name", type, p_node_id, validated_name);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "set_parameter_name", type, p_node_id, node->get_parameter_name());
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "update_node_deferred", type, p_node_id);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "update_node_deferred", type, p_node_id);
|
||||
|
||||
undo_redo->add_do_method(this, "_update_uniforms", true);
|
||||
undo_redo->add_undo_method(this, "_update_uniforms", true);
|
||||
undo_redo->add_do_method(this, "_update_parameters", true);
|
||||
undo_redo->add_undo_method(this, "_update_parameters", true);
|
||||
|
||||
HashSet<String> changed_names;
|
||||
changed_names.insert(node->get_uniform_name());
|
||||
_update_uniform_refs(changed_names);
|
||||
changed_names.insert(node->get_parameter_name());
|
||||
_update_parameter_refs(changed_names);
|
||||
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_uniform_line_edit_focus_out(Object *line_edit, int p_node_id) {
|
||||
_uniform_line_edit_changed(Object::cast_to<LineEdit>(line_edit)->get_text(), p_node_id);
|
||||
void VisualShaderEditor::_parameter_line_edit_focus_out(Object *line_edit, int p_node_id) {
|
||||
_parameter_line_edit_changed(Object::cast_to<LineEdit>(line_edit)->get_text(), p_node_id);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output) {
|
||||
|
@ -2674,22 +2674,22 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
|||
if (!p_ops.is_empty()) {
|
||||
_setup_node(vsn, p_ops);
|
||||
}
|
||||
VisualShaderNodeUniformRef *uniform_ref = Object::cast_to<VisualShaderNodeUniformRef>(vsn);
|
||||
if (uniform_ref && to_node != -1 && to_slot != -1) {
|
||||
VisualShaderNodeParameterRef *parameter_ref = Object::cast_to<VisualShaderNodeParameterRef>(vsn);
|
||||
if (parameter_ref && to_node != -1 && to_slot != -1) {
|
||||
VisualShaderNode::PortType input_port_type = visual_shader->get_node(type, to_node)->get_input_port_type(to_slot);
|
||||
bool success = false;
|
||||
|
||||
for (int i = 0; i < uniform_ref->get_uniforms_count(); i++) {
|
||||
if (uniform_ref->get_port_type_by_index(i) == input_port_type) {
|
||||
uniform_ref->set_uniform_name(uniform_ref->get_uniform_name_by_index(i));
|
||||
for (int i = 0; i < parameter_ref->get_parameters_count(); i++) {
|
||||
if (parameter_ref->get_port_type_by_index(i) == input_port_type) {
|
||||
parameter_ref->set_parameter_name(parameter_ref->get_parameter_name_by_index(i));
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
for (int i = 0; i < uniform_ref->get_uniforms_count(); i++) {
|
||||
if (visual_shader->is_port_types_compatible(uniform_ref->get_port_type_by_index(i), input_port_type)) {
|
||||
uniform_ref->set_uniform_name(uniform_ref->get_uniform_name_by_index(i));
|
||||
for (int i = 0; i < parameter_ref->get_parameters_count(); i++) {
|
||||
if (visual_shader->is_port_types_compatible(parameter_ref->get_port_type_by_index(i), input_port_type)) {
|
||||
parameter_ref->set_parameter_name(parameter_ref->get_parameter_name_by_index(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2712,7 +2712,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
|||
bool is_cubemap = (Object::cast_to<VisualShaderNodeCubemap>(vsnode.ptr()) != nullptr);
|
||||
bool is_curve = (Object::cast_to<VisualShaderNodeCurveTexture>(vsnode.ptr()) != nullptr);
|
||||
bool is_curve_xyz = (Object::cast_to<VisualShaderNodeCurveXYZTexture>(vsnode.ptr()) != nullptr);
|
||||
bool is_uniform = (Object::cast_to<VisualShaderNodeUniform>(vsnode.ptr()) != nullptr);
|
||||
bool is_parameter = (Object::cast_to<VisualShaderNodeParameter>(vsnode.ptr()) != nullptr);
|
||||
|
||||
Point2 position = graph->get_scroll_ofs();
|
||||
|
||||
|
@ -2861,9 +2861,9 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri
|
|||
}
|
||||
_member_cancel();
|
||||
|
||||
if (is_uniform) {
|
||||
undo_redo->add_do_method(this, "_update_uniforms", true);
|
||||
undo_redo->add_undo_method(this, "_update_uniforms", true);
|
||||
if (is_parameter) {
|
||||
undo_redo->add_do_method(this, "_update_parameters", true);
|
||||
undo_redo->add_undo_method(this, "_update_parameters", true);
|
||||
}
|
||||
|
||||
if (is_curve) {
|
||||
|
@ -3118,7 +3118,7 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
|
|||
}
|
||||
}
|
||||
|
||||
HashSet<String> uniform_names;
|
||||
HashSet<String> parameter_names;
|
||||
|
||||
for (const int &F : p_nodes) {
|
||||
Ref<VisualShaderNode> node = visual_shader->get_node(type, F);
|
||||
|
@ -3141,9 +3141,9 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
|
|||
undo_redo->add_undo_method(expression, "set_expression", expression->get_expression());
|
||||
}
|
||||
|
||||
VisualShaderNodeUniform *uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
|
||||
if (uniform) {
|
||||
uniform_names.insert(uniform->get_uniform_name());
|
||||
VisualShaderNodeParameter *parameter = Object::cast_to<VisualShaderNodeParameter>(node.ptr());
|
||||
if (parameter) {
|
||||
parameter_names.insert(parameter->get_parameter_name());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3172,12 +3172,12 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
|
|||
undo_redo->add_do_method(graph_plugin.ptr(), "remove_node", type, F);
|
||||
}
|
||||
|
||||
// update uniform refs if any uniform has been deleted
|
||||
if (uniform_names.size() > 0) {
|
||||
undo_redo->add_do_method(this, "_update_uniforms", true);
|
||||
undo_redo->add_undo_method(this, "_update_uniforms", true);
|
||||
// update parameter refs if any parameter has been deleted
|
||||
if (parameter_names.size() > 0) {
|
||||
undo_redo->add_do_method(this, "_update_parameters", true);
|
||||
undo_redo->add_undo_method(this, "_update_parameters", true);
|
||||
|
||||
_update_uniform_refs(uniform_names);
|
||||
_update_parameter_refs(parameter_names);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3196,33 +3196,33 @@ void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_no
|
|||
}
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_uniform(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) {
|
||||
Ref<VisualShaderNodeUniform> uniform = visual_shader->get_node(p_type_id, p_node_id);
|
||||
ERR_FAIL_COND(!uniform.is_valid());
|
||||
void VisualShaderEditor::_update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) {
|
||||
Ref<VisualShaderNodeParameter> parameter = visual_shader->get_node(p_type_id, p_node_id);
|
||||
ERR_FAIL_COND(!parameter.is_valid());
|
||||
|
||||
String valid_name = visual_shader->validate_uniform_name(uniform->get_uniform_name(), uniform);
|
||||
uniform->set_uniform_name(valid_name);
|
||||
graph_plugin->set_uniform_name(p_type_id, p_node_id, valid_name);
|
||||
String valid_name = visual_shader->validate_parameter_name(parameter->get_parameter_name(), parameter);
|
||||
parameter->set_parameter_name(valid_name);
|
||||
graph_plugin->set_parameter_name(p_type_id, p_node_id, valid_name);
|
||||
|
||||
if (uniform->has_method("set_default_value_enabled")) {
|
||||
uniform->call("set_default_value_enabled", true);
|
||||
uniform->call("set_default_value", p_var);
|
||||
if (parameter->has_method("set_default_value_enabled")) {
|
||||
parameter->call("set_default_value_enabled", true);
|
||||
parameter->call("set_default_value", p_var);
|
||||
}
|
||||
if (p_preview_port != -1) {
|
||||
uniform->set_output_port_for_preview(p_preview_port);
|
||||
parameter->set_output_port_for_preview(p_preview_port);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
||||
void VisualShaderEditor::_convert_constants_to_parameters(bool p_vice_versa) {
|
||||
VisualShader::Type type_id = get_current_shader_type();
|
||||
|
||||
if (!p_vice_versa) {
|
||||
undo_redo->create_action(TTR("Convert Constant Node(s) To Uniform(s)"));
|
||||
undo_redo->create_action(TTR("Convert Constant Node(s) To Parameter(s)"));
|
||||
} else {
|
||||
undo_redo->create_action(TTR("Convert Uniform Node(s) To Constant(s)"));
|
||||
undo_redo->create_action(TTR("Convert Parameter Node(s) To Constant(s)"));
|
||||
}
|
||||
|
||||
const HashSet<int> ¤t_set = p_vice_versa ? selected_uniforms : selected_constants;
|
||||
const HashSet<int> ¤t_set = p_vice_versa ? selected_parameters : selected_constants;
|
||||
HashSet<String> deleted_names;
|
||||
|
||||
for (const int &E : current_set) {
|
||||
|
@ -3235,15 +3235,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeFloatConstant> float_const = Object::cast_to<VisualShaderNodeFloatConstant>(node.ptr());
|
||||
if (float_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeFloatConstant", "VisualShaderNodeFloatUniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeFloatConstant", "VisualShaderNodeFloatParameter");
|
||||
var = float_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeFloatUniform> float_uniform = Object::cast_to<VisualShaderNodeFloatUniform>(node.ptr());
|
||||
if (float_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeFloatUniform", "VisualShaderNodeFloatConstant");
|
||||
var = float_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeFloatParameter> float_parameter = Object::cast_to<VisualShaderNodeFloatParameter>(node.ptr());
|
||||
if (float_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeFloatParameter", "VisualShaderNodeFloatConstant");
|
||||
var = float_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3253,15 +3253,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeIntConstant> int_const = Object::cast_to<VisualShaderNodeIntConstant>(node.ptr());
|
||||
if (int_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeIntConstant", "VisualShaderNodeIntUniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeIntConstant", "VisualShaderNodeIntParameter");
|
||||
var = int_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeIntUniform> int_uniform = Object::cast_to<VisualShaderNodeIntUniform>(node.ptr());
|
||||
if (int_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeIntUniform", "VisualShaderNodeIntConstant");
|
||||
var = int_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeIntParameter> int_parameter = Object::cast_to<VisualShaderNodeIntParameter>(node.ptr());
|
||||
if (int_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeIntParameter", "VisualShaderNodeIntConstant");
|
||||
var = int_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3272,15 +3272,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeBooleanConstant> boolean_const = Object::cast_to<VisualShaderNodeBooleanConstant>(node.ptr());
|
||||
if (boolean_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeBooleanConstant", "VisualShaderNodeBooleanUniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeBooleanConstant", "VisualShaderNodeBooleanParameter");
|
||||
var = boolean_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeBooleanUniform> boolean_uniform = Object::cast_to<VisualShaderNodeBooleanUniform>(node.ptr());
|
||||
if (boolean_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanConstant");
|
||||
var = boolean_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeBooleanParameter> boolean_parameter = Object::cast_to<VisualShaderNodeBooleanParameter>(node.ptr());
|
||||
if (boolean_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeBooleanParameter", "VisualShaderNodeBooleanConstant");
|
||||
var = boolean_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3291,15 +3291,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeVec2Constant> vec2_const = Object::cast_to<VisualShaderNodeVec2Constant>(node.ptr());
|
||||
if (vec2_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec2Constant", "VisualShaderNodeVec2Uniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec2Constant", "VisualShaderNodeVec2Parameter");
|
||||
var = vec2_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeVec2Uniform> vec2_uniform = Object::cast_to<VisualShaderNodeVec2Uniform>(node.ptr());
|
||||
if (vec2_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec2Uniform", "VisualShaderNodeVec2Constant");
|
||||
var = vec2_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeVec2Parameter> vec2_parameter = Object::cast_to<VisualShaderNodeVec2Parameter>(node.ptr());
|
||||
if (vec2_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec2Parameter", "VisualShaderNodeVec2Constant");
|
||||
var = vec2_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3310,15 +3310,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeVec3Constant> vec3_const = Object::cast_to<VisualShaderNodeVec3Constant>(node.ptr());
|
||||
if (vec3_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec3Constant", "VisualShaderNodeVec3Uniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec3Constant", "VisualShaderNodeVec3Parameter");
|
||||
var = vec3_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeVec3Uniform> vec3_uniform = Object::cast_to<VisualShaderNodeVec3Uniform>(node.ptr());
|
||||
if (vec3_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Constant");
|
||||
var = vec3_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeVec3Parameter> vec3_parameter = Object::cast_to<VisualShaderNodeVec3Parameter>(node.ptr());
|
||||
if (vec3_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec3Parameter", "VisualShaderNodeVec3Constant");
|
||||
var = vec3_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3329,15 +3329,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeVec4Constant> vec4_const = Object::cast_to<VisualShaderNodeVec4Constant>(node.ptr());
|
||||
if (vec4_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec4Constant", "VisualShaderNodeVec4Uniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec4Constant", "VisualShaderNodeVec4Parameter");
|
||||
var = vec4_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeVec4Uniform> vec4_uniform = Object::cast_to<VisualShaderNodeVec4Uniform>(node.ptr());
|
||||
if (vec4_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec4Uniform", "VisualShaderNodeVec4Constant");
|
||||
var = vec4_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeVec4Parameter> vec4_parameter = Object::cast_to<VisualShaderNodeVec4Parameter>(node.ptr());
|
||||
if (vec4_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeVec4Parameter", "VisualShaderNodeVec4Constant");
|
||||
var = vec4_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3348,15 +3348,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeColorConstant> color_const = Object::cast_to<VisualShaderNodeColorConstant>(node.ptr());
|
||||
if (color_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeColorConstant", "VisualShaderNodeColorUniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeColorConstant", "VisualShaderNodeColorParameter");
|
||||
var = color_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeColorUniform> color_uniform = Object::cast_to<VisualShaderNodeColorUniform>(node.ptr());
|
||||
if (color_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeColorUniform", "VisualShaderNodeColorConstant");
|
||||
var = color_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeColorParameter> color_parameter = Object::cast_to<VisualShaderNodeColorParameter>(node.ptr());
|
||||
if (color_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeColorParameter", "VisualShaderNodeColorConstant");
|
||||
var = color_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3367,15 +3367,15 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
if (!p_vice_versa) {
|
||||
Ref<VisualShaderNodeTransformConstant> transform_const = Object::cast_to<VisualShaderNodeTransformConstant>(node.ptr());
|
||||
if (transform_const.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeTransformConstant", "VisualShaderNodeTransformUniform");
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeTransformConstant", "VisualShaderNodeTransformParameter");
|
||||
var = transform_const->get_constant();
|
||||
caught = true;
|
||||
}
|
||||
} else {
|
||||
Ref<VisualShaderNodeTransformUniform> transform_uniform = Object::cast_to<VisualShaderNodeTransformUniform>(node.ptr());
|
||||
if (transform_uniform.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeTransformUniform", "VisualShaderNodeTransformConstant");
|
||||
var = transform_uniform->get_default_value();
|
||||
Ref<VisualShaderNodeTransformParameter> transform_parameter = Object::cast_to<VisualShaderNodeTransformParameter>(node.ptr());
|
||||
if (transform_parameter.is_valid()) {
|
||||
_replace_node(type_id, node_id, "VisualShaderNodeTransformParameter", "VisualShaderNodeTransformConstant");
|
||||
var = transform_parameter->get_default_value();
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
|
@ -3384,27 +3384,27 @@ void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
|
|||
int preview_port = node->get_output_port_for_preview();
|
||||
|
||||
if (!p_vice_versa) {
|
||||
undo_redo->add_do_method(this, "_update_uniform", type_id, node_id, var, preview_port);
|
||||
undo_redo->add_do_method(this, "_update_parameter", type_id, node_id, var, preview_port);
|
||||
undo_redo->add_undo_method(this, "_update_constant", type_id, node_id, var, preview_port);
|
||||
} else {
|
||||
undo_redo->add_do_method(this, "_update_constant", type_id, node_id, var, preview_port);
|
||||
undo_redo->add_undo_method(this, "_update_uniform", type_id, node_id, var, preview_port);
|
||||
undo_redo->add_undo_method(this, "_update_parameter", type_id, node_id, var, preview_port);
|
||||
|
||||
Ref<VisualShaderNodeUniform> uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
|
||||
ERR_CONTINUE(!uniform.is_valid());
|
||||
Ref<VisualShaderNodeParameter> parameter = Object::cast_to<VisualShaderNodeParameter>(node.ptr());
|
||||
ERR_CONTINUE(!parameter.is_valid());
|
||||
|
||||
deleted_names.insert(uniform->get_uniform_name());
|
||||
deleted_names.insert(parameter->get_parameter_name());
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, node_id);
|
||||
undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, node_id);
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(this, "_update_uniforms", true);
|
||||
undo_redo->add_undo_method(this, "_update_uniforms", true);
|
||||
undo_redo->add_do_method(this, "_update_parameters", true);
|
||||
undo_redo->add_undo_method(this, "_update_parameters", true);
|
||||
|
||||
if (deleted_names.size() > 0) {
|
||||
_update_uniform_refs(deleted_names);
|
||||
_update_parameter_refs(deleted_names);
|
||||
}
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
@ -3468,7 +3468,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
|||
|
||||
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) {
|
||||
selected_constants.clear();
|
||||
selected_uniforms.clear();
|
||||
selected_parameters.clear();
|
||||
selected_comment = -1;
|
||||
selected_float_constant = -1;
|
||||
|
||||
|
@ -3494,9 +3494,9 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
|||
if (float_constant_node != nullptr) {
|
||||
selected_float_constant = id;
|
||||
}
|
||||
VisualShaderNodeUniform *uniform_node = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
|
||||
if (uniform_node != nullptr && uniform_node->is_convertible_to_constant()) {
|
||||
selected_uniforms.insert(id);
|
||||
VisualShaderNodeParameter *parameter_node = Object::cast_to<VisualShaderNodeParameter>(node.ptr());
|
||||
if (parameter_node != nullptr && parameter_node->is_convertible_to_constant()) {
|
||||
selected_parameters.insert(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3533,11 +3533,11 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
|||
if (temp != -1) {
|
||||
popup_menu->remove_item(temp);
|
||||
}
|
||||
temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
|
||||
temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_CONSTANTS_TO_PARAMETERS);
|
||||
if (temp != -1) {
|
||||
popup_menu->remove_item(temp);
|
||||
}
|
||||
temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
|
||||
temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_PARAMETERS_TO_CONSTANTS);
|
||||
if (temp != -1) {
|
||||
popup_menu->remove_item(temp);
|
||||
}
|
||||
|
@ -3554,7 +3554,7 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
|||
popup_menu->remove_item(temp);
|
||||
}
|
||||
|
||||
if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
|
||||
if (selected_constants.size() > 0 || selected_parameters.size() > 0) {
|
||||
popup_menu->add_separator("", NodeMenuOptions::SEPARATOR2);
|
||||
|
||||
if (selected_float_constant != -1) {
|
||||
|
@ -3573,11 +3573,11 @@ void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
|
|||
}
|
||||
|
||||
if (selected_constants.size() > 0) {
|
||||
popup_menu->add_item(TTR("Convert Constant(s) to Uniform(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
|
||||
popup_menu->add_item(TTR("Convert Constant(s) to Parameter(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_PARAMETERS);
|
||||
}
|
||||
|
||||
if (selected_uniforms.size() > 0) {
|
||||
popup_menu->add_item(TTR("Convert Uniform(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
|
||||
if (selected_parameters.size() > 0) {
|
||||
popup_menu->add_item(TTR("Convert Parameter(s) to Constant(s)"), NodeMenuOptions::CONVERT_PARAMETERS_TO_CONSTANTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4124,32 +4124,32 @@ void VisualShaderEditor::_input_select_item(Ref<VisualShaderNodeInput> p_input,
|
|||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform_ref, String p_name) {
|
||||
String prev_name = p_uniform_ref->get_uniform_name();
|
||||
void VisualShaderEditor::_parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name) {
|
||||
String prev_name = p_parameter_ref->get_parameter_name();
|
||||
|
||||
if (p_name == prev_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool type_changed = p_uniform_ref->get_uniform_type_by_name(p_name) != p_uniform_ref->get_uniform_type_by_name(prev_name);
|
||||
bool type_changed = p_parameter_ref->get_parameter_type_by_name(p_name) != p_parameter_ref->get_parameter_type_by_name(prev_name);
|
||||
|
||||
Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
|
||||
undo_redo->create_action(TTR("UniformRef Name Changed"));
|
||||
undo_redo->create_action(TTR("ParameterRef Name Changed"));
|
||||
|
||||
undo_redo->add_do_method(p_uniform_ref.ptr(), "set_uniform_name", p_name);
|
||||
undo_redo->add_undo_method(p_uniform_ref.ptr(), "set_uniform_name", prev_name);
|
||||
undo_redo->add_do_method(p_parameter_ref.ptr(), "set_parameter_name", p_name);
|
||||
undo_redo->add_undo_method(p_parameter_ref.ptr(), "set_parameter_name", prev_name);
|
||||
|
||||
// update output port
|
||||
for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) {
|
||||
VisualShader::Type type = VisualShader::Type(type_id);
|
||||
int id = visual_shader->find_node_id(type, p_uniform_ref);
|
||||
int id = visual_shader->find_node_id(type, p_parameter_ref);
|
||||
if (id != VisualShader::NODE_ID_INVALID) {
|
||||
if (type_changed) {
|
||||
List<VisualShader::Connection> conns;
|
||||
visual_shader->get_node_connections(type, &conns);
|
||||
for (const VisualShader::Connection &E : conns) {
|
||||
if (E.from_node == id) {
|
||||
if (visual_shader->is_port_types_compatible(p_uniform_ref->get_uniform_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) {
|
||||
if (visual_shader->is_port_types_compatible(p_parameter_ref->get_parameter_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) {
|
||||
continue;
|
||||
}
|
||||
undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port);
|
||||
|
@ -4442,11 +4442,11 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
|
|||
case NodeMenuOptions::CLEAR_COPY_BUFFER:
|
||||
_clear_copy_buffer();
|
||||
break;
|
||||
case NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS:
|
||||
_convert_constants_to_uniforms(false);
|
||||
case NodeMenuOptions::CONVERT_CONSTANTS_TO_PARAMETERS:
|
||||
_convert_constants_to_parameters(false);
|
||||
break;
|
||||
case NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS:
|
||||
_convert_constants_to_uniforms(true);
|
||||
case NodeMenuOptions::CONVERT_PARAMETERS_TO_CONSTANTS:
|
||||
_convert_constants_to_parameters(true);
|
||||
break;
|
||||
case NodeMenuOptions::SET_COMMENT_TITLE:
|
||||
_comment_title_popup_show(get_screen_position() + get_local_mouse_position(), selected_comment);
|
||||
|
@ -4598,7 +4598,7 @@ void VisualShaderEditor::_preview_size_changed() {
|
|||
}
|
||||
|
||||
static ShaderLanguage::DataType _get_global_shader_uniform_type(const StringName &p_variable) {
|
||||
RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_variable);
|
||||
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_variable);
|
||||
return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
|
||||
}
|
||||
|
||||
|
@ -4655,18 +4655,18 @@ void VisualShaderEditor::_bind_methods() {
|
|||
ClassDB::bind_method("_add_node", &VisualShaderEditor::_add_node);
|
||||
ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed);
|
||||
ClassDB::bind_method("_input_select_item", &VisualShaderEditor::_input_select_item);
|
||||
ClassDB::bind_method("_uniform_select_item", &VisualShaderEditor::_uniform_select_item);
|
||||
ClassDB::bind_method("_parameter_ref_select_item", &VisualShaderEditor::_parameter_ref_select_item);
|
||||
ClassDB::bind_method("_varying_select_item", &VisualShaderEditor::_varying_select_item);
|
||||
ClassDB::bind_method("_set_node_size", &VisualShaderEditor::_set_node_size);
|
||||
ClassDB::bind_method("_clear_copy_buffer", &VisualShaderEditor::_clear_copy_buffer);
|
||||
ClassDB::bind_method("_update_uniforms", &VisualShaderEditor::_update_uniforms);
|
||||
ClassDB::bind_method("_update_parameters", &VisualShaderEditor::_update_parameters);
|
||||
ClassDB::bind_method("_update_varyings", &VisualShaderEditor::_update_varyings);
|
||||
ClassDB::bind_method("_update_varying_tree", &VisualShaderEditor::_update_varying_tree);
|
||||
ClassDB::bind_method("_set_mode", &VisualShaderEditor::_set_mode);
|
||||
ClassDB::bind_method("_nodes_dragged", &VisualShaderEditor::_nodes_dragged);
|
||||
ClassDB::bind_method("_float_constant_selected", &VisualShaderEditor::_float_constant_selected);
|
||||
ClassDB::bind_method("_update_constant", &VisualShaderEditor::_update_constant);
|
||||
ClassDB::bind_method("_update_uniform", &VisualShaderEditor::_update_uniform);
|
||||
ClassDB::bind_method("_update_parameter", &VisualShaderEditor::_update_parameter);
|
||||
ClassDB::bind_method("_expand_output_port", &VisualShaderEditor::_expand_output_port);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_get_drag_data_fw"), &VisualShaderEditor::get_drag_data_fw);
|
||||
|
@ -5077,7 +5077,7 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
add_options.push_back(AddOption("SoftLight", "Color", "Operators", "VisualShaderNodeColorOp", TTR("SoftLight operator."), { VisualShaderNodeColorOp::OP_SOFT_LIGHT }, VisualShaderNode::PORT_TYPE_VECTOR_3D));
|
||||
|
||||
add_options.push_back(AddOption("ColorConstant", "Color", "Variables", "VisualShaderNodeColorConstant", TTR("Color constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
add_options.push_back(AddOption("ColorUniform", "Color", "Variables", "VisualShaderNodeColorUniform", TTR("Color uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
add_options.push_back(AddOption("ColorParameter", "Color", "Variables", "VisualShaderNodeColorParameter", TTR("Color parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
|
||||
// COMMON
|
||||
|
||||
|
@ -5107,7 +5107,7 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
add_options.push_back(AddOption("Is", "Conditional", "Common", "VisualShaderNodeIs", TTR("Returns the boolean result of the comparison between INF (or NaN) and a scalar parameter."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN));
|
||||
|
||||
add_options.push_back(AddOption("BooleanConstant", "Conditional", "Variables", "VisualShaderNodeBooleanConstant", TTR("Boolean constant."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN));
|
||||
add_options.push_back(AddOption("BooleanUniform", "Conditional", "Variables", "VisualShaderNodeBooleanUniform", TTR("Boolean uniform."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN));
|
||||
add_options.push_back(AddOption("BooleanParameter", "Conditional", "Variables", "VisualShaderNodeBooleanParameter", TTR("Boolean parameter."), {}, VisualShaderNode::PORT_TYPE_BOOLEAN));
|
||||
|
||||
// INPUT
|
||||
|
||||
|
@ -5396,8 +5396,8 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
|
||||
add_options.push_back(AddOption("FloatConstant", "Scalar", "Variables", "VisualShaderNodeFloatConstant", TTR("Scalar floating-point constant."), {}, VisualShaderNode::PORT_TYPE_SCALAR));
|
||||
add_options.push_back(AddOption("IntConstant", "Scalar", "Variables", "VisualShaderNodeIntConstant", TTR("Scalar integer constant."), {}, VisualShaderNode::PORT_TYPE_SCALAR_INT));
|
||||
add_options.push_back(AddOption("FloatUniform", "Scalar", "Variables", "VisualShaderNodeFloatUniform", TTR("Scalar floating-point uniform."), {}, VisualShaderNode::PORT_TYPE_SCALAR));
|
||||
add_options.push_back(AddOption("IntUniform", "Scalar", "Variables", "VisualShaderNodeIntUniform", TTR("Scalar integer uniform."), {}, VisualShaderNode::PORT_TYPE_SCALAR_INT));
|
||||
add_options.push_back(AddOption("FloatParameter", "Scalar", "Variables", "VisualShaderNodeFloatParameter", TTR("Scalar floating-point parameter."), {}, VisualShaderNode::PORT_TYPE_SCALAR));
|
||||
add_options.push_back(AddOption("IntParameter", "Scalar", "Variables", "VisualShaderNodeIntParameter", TTR("Scalar integer parameter."), {}, VisualShaderNode::PORT_TYPE_SCALAR_INT));
|
||||
|
||||
// SDF
|
||||
{
|
||||
|
@ -5429,11 +5429,11 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
add_options.push_back(AddOption("UVPanning", "Textures", "Functions", "VisualShaderNodeUVFunc", TTR("Apply panning function on texture coordinates."), { VisualShaderNodeUVFunc::FUNC_PANNING }, VisualShaderNode::PORT_TYPE_VECTOR_2D));
|
||||
add_options.push_back(AddOption("UVScaling", "Textures", "Functions", "VisualShaderNodeUVFunc", TTR("Apply scaling function on texture coordinates."), { VisualShaderNodeUVFunc::FUNC_SCALING }, VisualShaderNode::PORT_TYPE_VECTOR_2D));
|
||||
|
||||
add_options.push_back(AddOption("CubeMapUniform", "Textures", "Variables", "VisualShaderNodeCubemapUniform", TTR("Cubic texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("TextureUniform", "Textures", "Variables", "VisualShaderNodeTextureUniform", TTR("2D texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("TextureUniformTriplanar", "Textures", "Variables", "VisualShaderNodeTextureUniformTriplanar", TTR("2D texture uniform lookup with triplanar."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
|
||||
add_options.push_back(AddOption("Texture2DArrayUniform", "Textures", "Variables", "VisualShaderNodeTexture2DArrayUniform", TTR("2D array of textures uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("Texture3DUniform", "Textures", "Variables", "VisualShaderNodeTexture3DUniform", TTR("3D texture uniform lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("CubeMapParameter", "Textures", "Variables", "VisualShaderNodeCubemapParameter", TTR("Cubic texture parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("Texture2DParameter", "Textures", "Variables", "VisualShaderNodeTexture2DParameter", TTR("2D texture parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("TextureParameterTriplanar", "Textures", "Variables", "VisualShaderNodeTextureParameterTriplanar", TTR("2D texture parameter lookup with triplanar."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
|
||||
add_options.push_back(AddOption("Texture2DArrayParameter", "Textures", "Variables", "VisualShaderNodeTexture2DArrayParameter", TTR("2D array of textures parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
add_options.push_back(AddOption("Texture3DParameter", "Textures", "Variables", "VisualShaderNodeTexture3DParameter", TTR("3D texture parameter lookup."), {}, VisualShaderNode::PORT_TYPE_SAMPLER));
|
||||
|
||||
// TRANSFORM
|
||||
|
||||
|
@ -5457,7 +5457,7 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
add_options.push_back(AddOption("TransformVectorMult", "Transform", "Operators", "VisualShaderNodeTransformVecMult", TTR("Multiplies vector by transform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D));
|
||||
|
||||
add_options.push_back(AddOption("TransformConstant", "Transform", "Variables", "VisualShaderNodeTransformConstant", TTR("Transform constant."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM));
|
||||
add_options.push_back(AddOption("TransformUniform", "Transform", "Variables", "VisualShaderNodeTransformUniform", TTR("Transform uniform."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM));
|
||||
add_options.push_back(AddOption("TransformParameter", "Transform", "Variables", "VisualShaderNodeTransformParameter", TTR("Transform parameter."), {}, VisualShaderNode::PORT_TYPE_TRANSFORM));
|
||||
|
||||
// UTILITY
|
||||
|
||||
|
@ -5659,18 +5659,18 @@ VisualShaderEditor::VisualShaderEditor() {
|
|||
add_options.push_back(AddOption("Subtract", "Vector", "Operators", "VisualShaderNodeVectorOp", TTR("Subtracts 4D vector from 4D vector."), { VisualShaderNodeVectorOp::OP_SUB, VisualShaderNodeVectorOp::OP_TYPE_VECTOR_4D }, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
|
||||
add_options.push_back(AddOption("Vector2Constant", "Vector", "Variables", "VisualShaderNodeVec2Constant", TTR("2D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_2D));
|
||||
add_options.push_back(AddOption("Vector2Uniform", "Vector", "Variables", "VisualShaderNodeVec2Uniform", TTR("2D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_2D));
|
||||
add_options.push_back(AddOption("Vector2Parameter", "Vector", "Variables", "VisualShaderNodeVec2Parameter", TTR("2D vector parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_2D));
|
||||
add_options.push_back(AddOption("Vector3Constant", "Vector", "Variables", "VisualShaderNodeVec3Constant", TTR("3D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D));
|
||||
add_options.push_back(AddOption("Vector3Uniform", "Vector", "Variables", "VisualShaderNodeVec3Uniform", TTR("3D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D));
|
||||
add_options.push_back(AddOption("Vector3Parameter", "Vector", "Variables", "VisualShaderNodeVec3Parameter", TTR("3D vector parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_3D));
|
||||
add_options.push_back(AddOption("Vector4Constant", "Vector", "Variables", "VisualShaderNodeVec4Constant", TTR("4D vector constant."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
add_options.push_back(AddOption("Vector4Uniform", "Vector", "Variables", "VisualShaderNodeVec4Uniform", TTR("4D vector uniform."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
add_options.push_back(AddOption("Vector4Parameter", "Vector", "Variables", "VisualShaderNodeVec4Parameter", TTR("4D vector parameter."), {}, VisualShaderNode::PORT_TYPE_VECTOR_4D));
|
||||
|
||||
// SPECIAL
|
||||
|
||||
add_options.push_back(AddOption("Comment", "Special", "", "VisualShaderNodeComment", TTR("A rectangular area with a description string for better graph organization.")));
|
||||
add_options.push_back(AddOption("Expression", "Special", "", "VisualShaderNodeExpression", TTR("Custom Godot Shader Language expression, with custom amount of input and output ports. This is a direct injection of code into the vertex/fragment/light function, do not use it to write the function declarations inside.")));
|
||||
add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, uniforms and constants.")));
|
||||
add_options.push_back(AddOption("UniformRef", "Special", "", "VisualShaderNodeUniformRef", TTR("A reference to an existing uniform.")));
|
||||
add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, parameters and constants.")));
|
||||
add_options.push_back(AddOption("ParameterRef", "Special", "", "VisualShaderNodeParameterRef", TTR("A reference to an existing parameter.")));
|
||||
add_options.push_back(AddOption("VaryingGetter", "Special", "", "VisualShaderNodeVaryingGetter", TTR("Get varying parameter."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL));
|
||||
add_options.push_back(AddOption("VaryingSetter", "Special", "", "VisualShaderNodeVaryingSetter", TTR("Set varying parameter."), {}, -1, TYPE_FLAGS_VERTEX | TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
|
||||
add_options.push_back(AddOption("VaryingGetter", "Special", "", "VisualShaderNodeVaryingGetter", TTR("Get varying parameter."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
|
||||
|
@ -5826,28 +5826,28 @@ public:
|
|||
|
||||
////////////////
|
||||
|
||||
class VisualShaderNodePluginUniformRefEditor : public OptionButton {
|
||||
GDCLASS(VisualShaderNodePluginUniformRefEditor, OptionButton);
|
||||
class VisualShaderNodePluginParameterRefEditor : public OptionButton {
|
||||
GDCLASS(VisualShaderNodePluginParameterRefEditor, OptionButton);
|
||||
|
||||
VisualShaderEditor *editor = nullptr;
|
||||
Ref<VisualShaderNodeUniformRef> uniform_ref;
|
||||
Ref<VisualShaderNodeParameterRef> parameter_ref;
|
||||
|
||||
public:
|
||||
void _notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
connect("item_selected", callable_mp(this, &VisualShaderNodePluginUniformRefEditor::_item_selected));
|
||||
connect("item_selected", callable_mp(this, &VisualShaderNodePluginParameterRefEditor::_item_selected));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void _item_selected(int p_item) {
|
||||
editor->call_deferred(SNAME("_uniform_select_item"), uniform_ref, get_item_text(p_item));
|
||||
editor->call_deferred(SNAME("_parameter_ref_select_item"), parameter_ref, get_item_text(p_item));
|
||||
}
|
||||
|
||||
void setup(VisualShaderEditor *p_editor, const Ref<VisualShaderNodeUniformRef> &p_uniform_ref) {
|
||||
void setup(VisualShaderEditor *p_editor, const Ref<VisualShaderNodeParameterRef> &p_parameter_ref) {
|
||||
editor = p_editor;
|
||||
uniform_ref = p_uniform_ref;
|
||||
parameter_ref = p_parameter_ref;
|
||||
|
||||
Ref<Texture2D> type_icon[] = {
|
||||
EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")),
|
||||
|
@ -5863,11 +5863,11 @@ public:
|
|||
|
||||
add_item("[None]");
|
||||
int to_select = -1;
|
||||
for (int i = 0; i < p_uniform_ref->get_uniforms_count(); i++) {
|
||||
if (p_uniform_ref->get_uniform_name() == p_uniform_ref->get_uniform_name_by_index(i)) {
|
||||
for (int i = 0; i < p_parameter_ref->get_parameters_count(); i++) {
|
||||
if (p_parameter_ref->get_parameter_name() == p_parameter_ref->get_parameter_name_by_index(i)) {
|
||||
to_select = i + 1;
|
||||
}
|
||||
add_icon_item(type_icon[p_uniform_ref->get_uniform_type_by_index(i)], p_uniform_ref->get_uniform_name_by_index(i));
|
||||
add_icon_item(type_icon[p_parameter_ref->get_parameter_type_by_index(i)], p_parameter_ref->get_parameter_name_by_index(i));
|
||||
}
|
||||
|
||||
if (to_select >= 0) {
|
||||
|
@ -6011,8 +6011,8 @@ Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_par
|
|||
return editor;
|
||||
}
|
||||
|
||||
if (p_node->is_class("VisualShaderNodeUniformRef")) {
|
||||
VisualShaderNodePluginUniformRefEditor *editor = memnew(VisualShaderNodePluginUniformRefEditor);
|
||||
if (p_node->is_class("VisualShaderNodeParameterRef")) {
|
||||
VisualShaderNodePluginParameterRefEditor *editor = memnew(VisualShaderNodePluginParameterRefEditor);
|
||||
editor->setup(vseditor, p_node);
|
||||
return editor;
|
||||
}
|
||||
|
@ -6222,7 +6222,7 @@ void VisualShaderNodePortPreview::_shader_changed() {
|
|||
preview_shader->set_code(shader_code);
|
||||
for (int i = 0; i < default_textures.size(); i++) {
|
||||
for (int j = 0; j < default_textures[i].params.size(); j++) {
|
||||
preview_shader->set_default_texture_param(default_textures[i].name, default_textures[i].params[j], j);
|
||||
preview_shader->set_default_texture_parameter(default_textures[i].name, default_textures[i].params[j], j);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ private:
|
|||
HashMap<int, InputPort> input_ports;
|
||||
HashMap<int, Port> output_ports;
|
||||
VBoxContainer *preview_box = nullptr;
|
||||
LineEdit *uniform_name = nullptr;
|
||||
LineEdit *parameter_name = nullptr;
|
||||
CodeEdit *expression_edit = nullptr;
|
||||
CurveEditor *curve_editors[3] = { nullptr, nullptr, nullptr };
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
void set_connections(const List<VisualShader::Connection> &p_connections);
|
||||
void register_link(VisualShader::Type p_type, int p_id, VisualShaderNode *p_visual_node, GraphNode *p_graph_node);
|
||||
void register_output_port(int p_id, int p_port, TextureButton *p_button);
|
||||
void register_uniform_name(int p_id, LineEdit *p_uniform_name);
|
||||
void register_parameter_name(int p_id, LineEdit *p_parameter_name);
|
||||
void register_default_input_button(int p_node_id, int p_port_id, Button *p_button);
|
||||
void register_expression_edit(int p_node_id, CodeEdit *p_expression_edit);
|
||||
void register_curve_editor(int p_node_id, int p_index, CurveEditor *p_curve_editor);
|
||||
|
@ -129,8 +129,8 @@ public:
|
|||
void set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position);
|
||||
void refresh_node_ports(VisualShader::Type p_type, int p_node);
|
||||
void set_input_port_default_value(VisualShader::Type p_type, int p_node_id, int p_port_id, Variant p_value);
|
||||
void update_uniform_refs();
|
||||
void set_uniform_name(VisualShader::Type p_type, int p_node_id, const String &p_name);
|
||||
void update_parameter_refs();
|
||||
void set_parameter_name(VisualShader::Type p_type, int p_node_id, const String &p_name);
|
||||
void update_curve(int p_node_id);
|
||||
void update_curve_xyz(int p_node_id);
|
||||
void set_expression(VisualShader::Type p_type, int p_node_id, const String &p_expression);
|
||||
|
@ -269,8 +269,8 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
CLEAR_COPY_BUFFER,
|
||||
SEPARATOR2, // ignore
|
||||
FLOAT_CONSTANTS,
|
||||
CONVERT_CONSTANTS_TO_UNIFORMS,
|
||||
CONVERT_UNIFORMS_TO_CONSTANTS,
|
||||
CONVERT_CONSTANTS_TO_PARAMETERS,
|
||||
CONVERT_PARAMETERS_TO_CONSTANTS,
|
||||
SEPARATOR3, // ignore
|
||||
SET_COMMENT_TITLE,
|
||||
SET_COMMENT_DESCRIPTION,
|
||||
|
@ -340,7 +340,7 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
int curve_xyz_node_option_idx;
|
||||
List<String> keyword_list;
|
||||
|
||||
List<VisualShaderNodeUniformRef> uniform_refs;
|
||||
List<VisualShaderNodeParameterRef> uniform_refs;
|
||||
|
||||
void _draw_color_over_button(Object *obj, Color p_color);
|
||||
|
||||
|
@ -390,14 +390,14 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
int from_slot = -1;
|
||||
|
||||
HashSet<int> selected_constants;
|
||||
HashSet<int> selected_uniforms;
|
||||
HashSet<int> selected_parameters;
|
||||
int selected_comment = -1;
|
||||
int selected_float_constant = -1;
|
||||
|
||||
void _convert_constants_to_uniforms(bool p_vice_versa);
|
||||
void _convert_constants_to_parameters(bool p_vice_versa);
|
||||
void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to);
|
||||
void _update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port);
|
||||
void _update_uniform(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port);
|
||||
void _update_parameter(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port);
|
||||
|
||||
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
|
||||
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
|
||||
|
@ -413,8 +413,8 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
void _comment_desc_confirm();
|
||||
void _comment_desc_text_changed();
|
||||
|
||||
void _uniform_line_edit_changed(const String &p_text, int p_node_id);
|
||||
void _uniform_line_edit_focus_out(Object *line_edit, int p_node_id);
|
||||
void _parameter_line_edit_changed(const String &p_text, int p_node_id);
|
||||
void _parameter_line_edit_focus_out(Object *line_edit, int p_node_id);
|
||||
|
||||
void _port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output);
|
||||
|
||||
|
@ -449,7 +449,7 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
void _custom_mode_toggled(bool p_enabled);
|
||||
|
||||
void _input_select_item(Ref<VisualShaderNodeInput> input, String name);
|
||||
void _uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform, String p_name);
|
||||
void _parameter_ref_select_item(Ref<VisualShaderNodeParameterRef> p_parameter_ref, String p_name);
|
||||
void _varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name);
|
||||
|
||||
void _float_constant_selected(int p_which);
|
||||
|
@ -498,8 +498,8 @@ class VisualShaderEditor : public VBoxContainer {
|
|||
|
||||
bool _is_available(int p_mode);
|
||||
void _update_created_node(GraphNode *node);
|
||||
void _update_uniforms(bool p_update_refs);
|
||||
void _update_uniform_refs(HashSet<String> &p_names);
|
||||
void _update_parameters(bool p_update_refs);
|
||||
void _update_parameter_refs(HashSet<String> &p_names);
|
||||
void _update_varyings();
|
||||
|
||||
void _visibility_changed();
|
||||
|
|
|
@ -513,7 +513,6 @@ static const char *gdscript_function_renames[][2] = {
|
|||
{ "set_region_filter_clip", "set_region_filter_clip_enabled" }, // Sprite2D
|
||||
{ "set_rotate", "set_rotates" }, // PathFollow2D
|
||||
{ "set_scancode", "set_keycode" }, // InputEventKey
|
||||
{ "set_shader_param", "set_shader_uniform" }, // ShaderMaterial
|
||||
{ "set_shift", "set_shift_pressed" }, // InputEventWithModifiers
|
||||
{ "set_size_override", "set_size_2d_override" }, // SubViewport broke ImageTexture
|
||||
{ "set_size_override_stretch", "set_size_2d_override_stretch" }, // SubViewport
|
||||
|
@ -549,6 +548,10 @@ static const char *gdscript_function_renames[][2] = {
|
|||
{ "update_gizmo", "update_gizmos" }, // Node3D
|
||||
{ "viewport_set_use_arvr", "viewport_set_use_xr" }, // RenderingServer
|
||||
{ "warp_mouse_position", "warp_mouse" }, // Input
|
||||
{ "set_shader_param", "set_shader_parameter" }, // ShaderMaterial
|
||||
{ "get_shader_param", "get_shader_parameter" }, // ShaderMaterial
|
||||
{ "set_uniform_name", "set_parameter_name" }, // ParameterRef
|
||||
{ "get_uniform_name", "get_parameter_name" }, // ParameterRef
|
||||
|
||||
// Builtin types
|
||||
// Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed
|
||||
|
@ -956,6 +959,10 @@ static const char *csharp_function_renames[][2] = {
|
|||
{ "UpdateGizmo", "UpdateGizmos" }, // Node3D
|
||||
{ "ViewportSetUseArvr", "ViewportSetUseXr" }, // RenderingServer
|
||||
{ "WarpMousePosition", "WarpMouse" }, // Input
|
||||
{ "SetShaderParam", "SetShaderParameter" }, // ShaderMaterial
|
||||
{ "GetShaderParam", "GetShaderParameter" }, // ShaderMaterial
|
||||
{ "SetUniformName", "SetParameterName" }, // ParameterRef
|
||||
{ "GetUniformName", "GetParameterName" }, // ParameterRef
|
||||
|
||||
// Builtin types
|
||||
// { "Empty", "IsEmpty" }, // Array - Used as custom rule // Be careful, this will be used everywhere
|
||||
|
@ -1474,7 +1481,6 @@ static const char *class_renames[][2] = {
|
|||
{ "VisualInstance", "VisualInstance3D" },
|
||||
{ "VisualServer", "RenderingServer" },
|
||||
{ "VisualShaderNodeCubeMap", "VisualShaderNodeCubemap" },
|
||||
{ "VisualShaderNodeCubeMapUniform", "VisualShaderNodeCubemapUniform" },
|
||||
{ "VisualShaderNodeScalarClamp", "VisualShaderNodeClamp" },
|
||||
{ "VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant" },
|
||||
{ "VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc" },
|
||||
|
@ -1483,7 +1489,6 @@ static const char *class_renames[][2] = {
|
|||
{ "VisualShaderNodeScalarSmoothStep", "VisualShaderNodeSmoothStep" },
|
||||
{ "VisualShaderNodeScalarSwitch", "VisualShaderNodeSwitch" },
|
||||
{ "VisualShaderNodeScalarTransformMult", "VisualShaderNodeTransformOp" },
|
||||
{ "VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform" },
|
||||
{ "VisualShaderNodeTransformMult", "VisualShaderNode" },
|
||||
{ "VisualShaderNodeVectorClamp", "VisualShaderNodeClamp" },
|
||||
{ "VisualShaderNodeVectorInterp", "VisualShaderNodeMix" },
|
||||
|
@ -1491,6 +1496,16 @@ static const char *class_renames[][2] = {
|
|||
{ "VisualShaderNodeVectorScalarSmoothStep", "VisualShaderNodeSmoothStep" },
|
||||
{ "VisualShaderNodeVectorScalarStep", "VisualShaderNodeStep" },
|
||||
{ "VisualShaderNodeVectorSmoothStep", "VisualShaderNodeSmoothStep" },
|
||||
{ "VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanParameter" },
|
||||
{ "VisualShaderNodeColorUniform", "VisualShaderNodeColorParameter" },
|
||||
{ "VisualShaderNodeScalarUniform", "VisualShaderNodeFloatParameter" },
|
||||
{ "VisualShaderNodeCubemapUniform", "VisualShaderNodeCubemapParameter" },
|
||||
{ "VisualShaderNodeTextureUniform", "VisualShaderNodeTexture2DParameter" },
|
||||
{ "VisualShaderNodeTextureUniformTriplanar", "VisualShaderNodeTextureParameterTriplanar" },
|
||||
{ "VisualShaderNodeTransformUniform", "VisualShaderNodeTransformParameter" },
|
||||
{ "VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Parameter" },
|
||||
{ "VisualShaderNodeUniform", "VisualShaderNodeParameter" },
|
||||
{ "VisualShaderNodeUniformRef", "VisualShaderNodeParameterRef" },
|
||||
{ "WebRTCDataChannelGDNative", "WebRTCDataChannelExtension" },
|
||||
{ "WebRTCMultiplayer", "WebRTCMultiplayerPeer" },
|
||||
{ "WebRTCPeerConnectionGDNative", "WebRTCPeerConnectionExtension" },
|
||||
|
|
|
@ -80,7 +80,7 @@ protected:
|
|||
}
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value) {
|
||||
Variant existing = RS::get_singleton()->global_shader_uniform_get(p_name);
|
||||
Variant existing = RS::get_singleton()->global_shader_parameter_get(p_name);
|
||||
|
||||
if (existing.get_type() == Variant::NIL) {
|
||||
return false;
|
||||
|
@ -89,9 +89,9 @@ protected:
|
|||
Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_undo_redo();
|
||||
|
||||
undo_redo->create_action(TTR("Set Shader Global Variable"));
|
||||
undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_set", p_name, p_value);
|
||||
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_set", p_name, existing);
|
||||
RS::GlobalShaderUniformType type = RS::get_singleton()->global_shader_uniform_get_type(p_name);
|
||||
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_set", p_name, p_value);
|
||||
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_set", p_name, existing);
|
||||
RS::GlobalShaderParameterType type = RS::get_singleton()->global_shader_parameter_get_type(p_name);
|
||||
Dictionary gv;
|
||||
gv["type"] = global_var_type_names[type];
|
||||
if (type >= RS::GLOBAL_VAR_TYPE_SAMPLER2D) {
|
||||
|
@ -118,17 +118,17 @@ protected:
|
|||
}
|
||||
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const {
|
||||
r_ret = RS::get_singleton()->global_shader_uniform_get(p_name);
|
||||
r_ret = RS::get_singleton()->global_shader_parameter_get(p_name);
|
||||
return r_ret.get_type() != Variant::NIL;
|
||||
}
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const {
|
||||
Vector<StringName> variables;
|
||||
variables = RS::get_singleton()->global_shader_uniform_get_list();
|
||||
variables = RS::get_singleton()->global_shader_parameter_get_list();
|
||||
for (int i = 0; i < variables.size(); i++) {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = variables[i];
|
||||
|
||||
switch (RS::get_singleton()->global_shader_uniform_get_type(variables[i])) {
|
||||
switch (RS::get_singleton()->global_shader_parameter_get_type(variables[i])) {
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
pinfo.type = Variant::BOOL;
|
||||
} break;
|
||||
|
@ -242,7 +242,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static Variant create_var(RS::GlobalShaderUniformType p_type) {
|
||||
static Variant create_var(RS::GlobalShaderParameterType p_type) {
|
||||
switch (p_type) {
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
return false;
|
||||
|
@ -381,8 +381,8 @@ void ShaderGlobalsEditor::_variable_added() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (RenderingServer::get_singleton()->global_shader_uniform_get(var).get_type() != Variant::NIL) {
|
||||
EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader uniform '%s' already exists'"), var));
|
||||
if (RenderingServer::get_singleton()->global_shader_parameter_get(var).get_type() != Variant::NIL) {
|
||||
EditorNode::get_singleton()->show_warning(vformat(TTR("Global shader parameter '%s' already exists'"), var));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -396,11 +396,11 @@ void ShaderGlobalsEditor::_variable_added() {
|
|||
|
||||
Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
||||
|
||||
Variant value = create_var(RS::GlobalShaderUniformType(variable_type->get_selected()));
|
||||
Variant value = create_var(RS::GlobalShaderParameterType(variable_type->get_selected()));
|
||||
|
||||
undo_redo->create_action(TTR("Add Shader Global Uniform"));
|
||||
undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_add", var, RS::GlobalShaderUniformType(variable_type->get_selected()), value);
|
||||
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_remove", var);
|
||||
undo_redo->create_action(TTR("Add Shader Global Parameter"));
|
||||
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_add", var, RS::GlobalShaderParameterType(variable_type->get_selected()), value);
|
||||
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_remove", var);
|
||||
Dictionary gv;
|
||||
gv["type"] = global_var_type_names[variable_type->get_selected()];
|
||||
gv["value"] = value;
|
||||
|
@ -415,9 +415,9 @@ void ShaderGlobalsEditor::_variable_added() {
|
|||
void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) {
|
||||
Ref<EditorUndoRedoManager> undo_redo = EditorNode::get_singleton()->get_undo_redo();
|
||||
|
||||
undo_redo->create_action(TTR("Add Shader Global Uniform"));
|
||||
undo_redo->add_do_method(RS::get_singleton(), "global_shader_uniform_remove", p_variable);
|
||||
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_uniform_add", p_variable, RS::get_singleton()->global_shader_uniform_get_type(p_variable), RS::get_singleton()->global_shader_uniform_get(p_variable));
|
||||
undo_redo->create_action(TTR("Add Shader Global Parameter"));
|
||||
undo_redo->add_do_method(RS::get_singleton(), "global_shader_parameter_remove", p_variable);
|
||||
undo_redo->add_undo_method(RS::get_singleton(), "global_shader_parameter_add", p_variable, RS::get_singleton()->global_shader_parameter_get_type(p_variable), RS::get_singleton()->global_shader_parameter_get(p_variable));
|
||||
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, Variant());
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "shader_globals/" + p_variable, ProjectSettings::get_singleton()->get("shader_globals/" + p_variable));
|
||||
|
|
|
@ -2209,7 +2209,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
|||
// able to load resources, load the global shader variables.
|
||||
// If running on editor, don't load the textures because the editor
|
||||
// may want to import them first. Editor will reload those later.
|
||||
rendering_server->global_shader_uniforms_load_settings(!editor);
|
||||
rendering_server->global_shader_parameters_load_settings(!editor);
|
||||
}
|
||||
|
||||
_start_success = true;
|
||||
|
@ -3136,7 +3136,7 @@ void Main::cleanup(bool p_force) {
|
|||
RenderingServer::get_singleton()->sync();
|
||||
|
||||
//clear global shader variables before scene and other graphics stuff are deinitialized.
|
||||
rendering_server->global_shader_uniforms_clear();
|
||||
rendering_server->global_shader_parameters_clear();
|
||||
|
||||
if (xr_server) {
|
||||
// Now that we're unregistering properly in plugins we need to keep access to xr_server for a little longer
|
||||
|
|
|
@ -242,7 +242,7 @@ const StringName *GeometryInstance3D::_instance_uniform_get_remap(const StringNa
|
|||
bool GeometryInstance3D::_set(const StringName &p_name, const Variant &p_value) {
|
||||
const StringName *r = _instance_uniform_get_remap(p_name);
|
||||
if (r) {
|
||||
set_instance_shader_uniform(*r, p_value);
|
||||
set_instance_shader_parameter(*r, p_value);
|
||||
return true;
|
||||
}
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
|
@ -262,7 +262,7 @@ bool GeometryInstance3D::_set(const StringName &p_name, const Variant &p_value)
|
|||
bool GeometryInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
const StringName *r = _instance_uniform_get_remap(p_name);
|
||||
if (r) {
|
||||
r_ret = get_instance_shader_uniform(*r);
|
||||
r_ret = get_instance_shader_parameter(*r);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -271,10 +271,10 @@ bool GeometryInstance3D::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
|
||||
void GeometryInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
List<PropertyInfo> pinfo;
|
||||
RS::get_singleton()->instance_geometry_get_shader_uniform_list(get_instance(), &pinfo);
|
||||
RS::get_singleton()->instance_geometry_get_shader_parameter_list(get_instance(), &pinfo);
|
||||
for (PropertyInfo &pi : pinfo) {
|
||||
bool has_def_value = false;
|
||||
Variant def_value = RS::get_singleton()->instance_geometry_get_shader_uniform_default_value(get_instance(), pi.name);
|
||||
Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), pi.name);
|
||||
if (def_value.get_type() != Variant::NIL) {
|
||||
has_def_value = true;
|
||||
}
|
||||
|
@ -319,24 +319,24 @@ float GeometryInstance3D::get_lod_bias() const {
|
|||
return lod_bias;
|
||||
}
|
||||
|
||||
void GeometryInstance3D::set_instance_shader_uniform(const StringName &p_uniform, const Variant &p_value) {
|
||||
void GeometryInstance3D::set_instance_shader_parameter(const StringName &p_name, const Variant &p_value) {
|
||||
if (p_value.get_type() == Variant::NIL) {
|
||||
Variant def_value = RS::get_singleton()->instance_geometry_get_shader_uniform_default_value(get_instance(), p_uniform);
|
||||
RS::get_singleton()->instance_geometry_set_shader_uniform(get_instance(), p_uniform, def_value);
|
||||
Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), p_name);
|
||||
RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_name, def_value);
|
||||
instance_uniforms.erase(p_value);
|
||||
} else {
|
||||
instance_uniforms[p_uniform] = p_value;
|
||||
instance_uniforms[p_name] = p_value;
|
||||
if (p_value.get_type() == Variant::OBJECT) {
|
||||
RID tex_id = p_value;
|
||||
RS::get_singleton()->instance_geometry_set_shader_uniform(get_instance(), p_uniform, tex_id);
|
||||
RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_name, tex_id);
|
||||
} else {
|
||||
RS::get_singleton()->instance_geometry_set_shader_uniform(get_instance(), p_uniform, p_value);
|
||||
RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_name, p_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Variant GeometryInstance3D::get_instance_shader_uniform(const StringName &p_uniform) const {
|
||||
return RS::get_singleton()->instance_geometry_get_shader_uniform(get_instance(), p_uniform);
|
||||
Variant GeometryInstance3D::get_instance_shader_parameter(const StringName &p_name) const {
|
||||
return RS::get_singleton()->instance_geometry_get_shader_parameter(get_instance(), p_name);
|
||||
}
|
||||
|
||||
void GeometryInstance3D::set_custom_aabb(AABB aabb) {
|
||||
|
@ -434,8 +434,8 @@ void GeometryInstance3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_visibility_range_fade_mode", "mode"), &GeometryInstance3D::set_visibility_range_fade_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_visibility_range_fade_mode"), &GeometryInstance3D::get_visibility_range_fade_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_instance_shader_uniform", "uniform", "value"), &GeometryInstance3D::set_instance_shader_uniform);
|
||||
ClassDB::bind_method(D_METHOD("get_instance_shader_uniform", "uniform"), &GeometryInstance3D::get_instance_shader_uniform);
|
||||
ClassDB::bind_method(D_METHOD("set_instance_shader_parameter", "name", "value"), &GeometryInstance3D::set_instance_shader_parameter);
|
||||
ClassDB::bind_method(D_METHOD("get_instance_shader_parameter", "name"), &GeometryInstance3D::get_instance_shader_parameter);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &GeometryInstance3D::set_extra_cull_margin);
|
||||
ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance3D::get_extra_cull_margin);
|
||||
|
|
|
@ -178,8 +178,8 @@ public:
|
|||
void set_lightmap_scale(LightmapScale p_scale);
|
||||
LightmapScale get_lightmap_scale() const;
|
||||
|
||||
void set_instance_shader_uniform(const StringName &p_uniform, const Variant &p_value);
|
||||
Variant get_instance_shader_uniform(const StringName &p_uniform) const;
|
||||
void set_instance_shader_parameter(const StringName &p_name, const Variant &p_value);
|
||||
Variant get_instance_shader_parameter(const StringName &p_name) const;
|
||||
|
||||
void set_custom_aabb(AABB aabb);
|
||||
|
||||
|
|
|
@ -853,7 +853,7 @@ void ColorPicker::_hsv_draw(int p_which, Control *c) {
|
|||
} else if (p_which == 2) {
|
||||
c->draw_rect(Rect2(Point2(), c->get_size()), Color(1, 1, 1));
|
||||
if (actual_shape == SHAPE_VHS_CIRCLE || actual_shape == SHAPE_OKHSL_CIRCLE) {
|
||||
circle_mat->set_shader_uniform("v", v);
|
||||
circle_mat->set_shader_parameter("v", v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ bool ShaderGlobalsOverride::_set(const StringName &p_name, const Variant &p_valu
|
|||
if (active) {
|
||||
if (o->override.get_type() == Variant::OBJECT) {
|
||||
RID tex_rid = p_value;
|
||||
RS::get_singleton()->global_shader_uniform_set_override(*r, tex_rid);
|
||||
RS::get_singleton()->global_shader_parameter_set_override(*r, tex_rid);
|
||||
} else {
|
||||
RS::get_singleton()->global_shader_uniform_set_override(*r, p_value);
|
||||
RS::get_singleton()->global_shader_parameter_set_override(*r, p_value);
|
||||
}
|
||||
}
|
||||
o->in_use = p_value.get_type() != Variant::NIL;
|
||||
|
@ -93,13 +93,13 @@ bool ShaderGlobalsOverride::_get(const StringName &p_name, Variant &r_ret) const
|
|||
|
||||
void ShaderGlobalsOverride::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
Vector<StringName> variables;
|
||||
variables = RS::get_singleton()->global_shader_uniform_get_list();
|
||||
variables = RS::get_singleton()->global_shader_parameter_get_list();
|
||||
for (int i = 0; i < variables.size(); i++) {
|
||||
PropertyInfo pinfo;
|
||||
pinfo.name = "params/" + variables[i];
|
||||
pinfo.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CHECKABLE;
|
||||
|
||||
switch (RS::get_singleton()->global_shader_uniform_get_type(variables[i])) {
|
||||
switch (RS::get_singleton()->global_shader_parameter_get_type(variables[i])) {
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
pinfo.type = Variant::BOOL;
|
||||
} break;
|
||||
|
@ -234,9 +234,9 @@ void ShaderGlobalsOverride::_activate() {
|
|||
if (o->in_use && o->override.get_type() != Variant::NIL) {
|
||||
if (o->override.get_type() == Variant::OBJECT) {
|
||||
RID tex_rid = o->override;
|
||||
RS::get_singleton()->global_shader_uniform_set_override(E.key, tex_rid);
|
||||
RS::get_singleton()->global_shader_parameter_set_override(E.key, tex_rid);
|
||||
} else {
|
||||
RS::get_singleton()->global_shader_uniform_set_override(E.key, o->override);
|
||||
RS::get_singleton()->global_shader_parameter_set_override(E.key, o->override);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ void ShaderGlobalsOverride::_notification(int p_what) {
|
|||
for (const KeyValue<StringName, Override> &E : overrides) {
|
||||
const Override *o = &E.value;
|
||||
if (o->in_use) {
|
||||
RS::get_singleton()->global_shader_uniform_set_override(E.key, Variant());
|
||||
RS::get_singleton()->global_shader_parameter_set_override(E.key, Variant());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -638,21 +638,22 @@ void register_scene_types() {
|
|||
GDREGISTER_CLASS(VisualShaderNodeTexture2DArray);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTexture3D);
|
||||
GDREGISTER_CLASS(VisualShaderNodeCubemap);
|
||||
GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeUniformRef);
|
||||
GDREGISTER_CLASS(VisualShaderNodeFloatUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeIntUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeBooleanUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeColorUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeVec2Uniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeVec3Uniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeVec4Uniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTransformUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTextureUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTextureUniformTriplanar);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTexture2DArrayUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTexture3DUniform);
|
||||
GDREGISTER_CLASS(VisualShaderNodeCubemapUniform);
|
||||
GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeParameterRef);
|
||||
GDREGISTER_CLASS(VisualShaderNodeFloatParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeIntParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeBooleanParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeColorParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeVec2Parameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeVec3Parameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeVec4Parameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTransformParameter);
|
||||
GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeTextureParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTexture2DParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTextureParameterTriplanar);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTexture2DArrayParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeTexture3DParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeCubemapParameter);
|
||||
GDREGISTER_CLASS(VisualShaderNodeLinearSceneDepth);
|
||||
GDREGISTER_CLASS(VisualShaderNodeIf);
|
||||
GDREGISTER_CLASS(VisualShaderNodeSwitch);
|
||||
|
@ -1081,10 +1082,12 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("VisibilityNotifier2D", "VisibleOnScreenNotifier2D");
|
||||
ClassDB::add_compatibility_class("VisibilityNotifier3D", "VisibleOnScreenNotifier3D");
|
||||
ClassDB::add_compatibility_class("VisualServer", "RenderingServer");
|
||||
ClassDB::add_compatibility_class("World", "World3D");
|
||||
|
||||
// VisualShader classes.
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatUniform");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarClamp", "VisualShaderNodeClamp");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeVectorClamp", "VisualShaderNodeClamp");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarInterp", "VisualShaderNodeMix");
|
||||
|
@ -1098,7 +1101,17 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("VisualShaderNodeScalarTransformMult", "VisualShaderNodeTransformOp");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarDerivativeFunc", "VisualShaderNodeDerivativeFunc");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeVectorDerivativeFunc", "VisualShaderNodeDerivativeFunc");
|
||||
ClassDB::add_compatibility_class("World", "World3D");
|
||||
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeColorUniform", "VisualShaderNodeColorParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeScalarUniform", "VisualShaderNodeFloatParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeCubeMapUniform", "VisualShaderNodeCubeMapParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeTextureUniform", "VisualShaderNodeTexture2DParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeTextureUniformTriplanar", "VisualShaderNodeTextureParameterTriplanar");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeTransformUniform", "VisualShaderNodeTransformParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Parameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeUniform", "VisualShaderNodeParameter");
|
||||
ClassDB::add_compatibility_class("VisualShaderNodeUniformRef", "VisualShaderNodeParameterRef");
|
||||
|
||||
// Renamed during 4.0 alpha, added to ease transition between alphas.
|
||||
ClassDB::add_compatibility_class("AudioStreamOGGVorbis", "AudioStreamOggVorbis");
|
||||
|
|
|
@ -157,15 +157,16 @@ bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
|
|||
StringName pr = shader->remap_uniform(p_name);
|
||||
if (!pr) {
|
||||
String n = p_name;
|
||||
if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
if (n.find("shader_uniform/") == 0) { //backwards compatibility
|
||||
if (n.find("shader_parameter/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_parameter/", "");
|
||||
} else if (n.find("shader_uniform/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_uniform/", "");
|
||||
} else if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
}
|
||||
if (pr) {
|
||||
set_shader_uniform(pr, p_value);
|
||||
set_shader_parameter(pr, p_value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -178,11 +179,12 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
StringName pr = shader->remap_uniform(p_name);
|
||||
if (!pr) {
|
||||
String n = p_name;
|
||||
if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
if (n.find("shader_uniform/") == 0) { //backwards compatibility
|
||||
if (n.find("shader_parameter/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_parameter/", "");
|
||||
} else if (n.find("shader_uniform/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_uniform/", "");
|
||||
} else if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +303,7 @@ bool ShaderMaterial::_property_can_revert(const StringName &p_name) const {
|
|||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_uniform(p_name);
|
||||
if (pr) {
|
||||
Variant default_value = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
|
||||
Variant default_value = RenderingServer::get_singleton()->shader_get_parameter_default(shader->get_rid(), pr);
|
||||
Variant current_value;
|
||||
_get(p_name, current_value);
|
||||
return default_value.get_type() != Variant::NIL && default_value != current_value;
|
||||
|
@ -314,7 +316,7 @@ bool ShaderMaterial::_property_get_revert(const StringName &p_name, Variant &r_p
|
|||
if (shader.is_valid()) {
|
||||
StringName pr = shader->remap_uniform(p_name);
|
||||
if (pr) {
|
||||
r_property = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
|
||||
r_property = RenderingServer::get_singleton()->shader_get_parameter_default(shader->get_rid(), pr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -349,7 +351,7 @@ Ref<Shader> ShaderMaterial::get_shader() const {
|
|||
return shader;
|
||||
}
|
||||
|
||||
void ShaderMaterial::set_shader_uniform(const StringName &p_param, const Variant &p_value) {
|
||||
void ShaderMaterial::set_shader_parameter(const StringName &p_param, const Variant &p_value) {
|
||||
if (p_value.get_type() == Variant::NIL) {
|
||||
param_cache.erase(p_param);
|
||||
RS::get_singleton()->material_set_param(_get_material(), p_param, Variant());
|
||||
|
@ -369,7 +371,7 @@ void ShaderMaterial::set_shader_uniform(const StringName &p_param, const Variant
|
|||
}
|
||||
}
|
||||
|
||||
Variant ShaderMaterial::get_shader_uniform(const StringName &p_param) const {
|
||||
Variant ShaderMaterial::get_shader_parameter(const StringName &p_param) const {
|
||||
if (param_cache.has(p_param)) {
|
||||
return param_cache[p_param];
|
||||
} else {
|
||||
|
@ -384,20 +386,20 @@ void ShaderMaterial::_shader_changed() {
|
|||
void ShaderMaterial::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_shader", "shader"), &ShaderMaterial::set_shader);
|
||||
ClassDB::bind_method(D_METHOD("get_shader"), &ShaderMaterial::get_shader);
|
||||
ClassDB::bind_method(D_METHOD("set_shader_uniform", "param", "value"), &ShaderMaterial::set_shader_uniform);
|
||||
ClassDB::bind_method(D_METHOD("get_shader_uniform", "param"), &ShaderMaterial::get_shader_uniform);
|
||||
ClassDB::bind_method(D_METHOD("set_shader_parameter", "param", "value"), &ShaderMaterial::set_shader_parameter);
|
||||
ClassDB::bind_method(D_METHOD("get_shader_parameter", "param"), &ShaderMaterial::get_shader_parameter);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader");
|
||||
}
|
||||
|
||||
void ShaderMaterial::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
|
||||
String f = p_function.operator String();
|
||||
if ((f == "get_shader_uniform" || f == "set_shader_uniform") && p_idx == 0) {
|
||||
if ((f == "get_shader_parameter" || f == "set_shader_parameter") && p_idx == 0) {
|
||||
if (shader.is_valid()) {
|
||||
List<PropertyInfo> pl;
|
||||
shader->get_shader_uniform_list(&pl);
|
||||
for (const PropertyInfo &E : pl) {
|
||||
r_options->push_back(E.name.replace_first("shader_uniform/", "").quote());
|
||||
r_options->push_back(E.name.replace_first("shader_parameter/", "").quote());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@ public:
|
|||
void set_shader(const Ref<Shader> &p_shader);
|
||||
Ref<Shader> get_shader() const;
|
||||
|
||||
void set_shader_uniform(const StringName &p_param, const Variant &p_value);
|
||||
Variant get_shader_uniform(const StringName &p_param) const;
|
||||
void set_shader_parameter(const StringName &p_param, const Variant &p_value);
|
||||
Variant get_shader_parameter(const StringName &p_param) const;
|
||||
|
||||
virtual Shader::Mode get_shader_mode() const override;
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ void Shader::get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_gr
|
|||
_update_shader();
|
||||
|
||||
List<PropertyInfo> local;
|
||||
RenderingServer::get_singleton()->shader_get_shader_uniform_list(shader, &local);
|
||||
RenderingServer::get_singleton()->get_shader_parameter_list(shader, &local);
|
||||
params_cache.clear();
|
||||
params_cache_dirty = false;
|
||||
|
||||
|
@ -138,35 +138,35 @@ RID Shader::get_rid() const {
|
|||
return shader;
|
||||
}
|
||||
|
||||
void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture2D> &p_texture, int p_index) {
|
||||
void Shader::set_default_texture_parameter(const StringName &p_name, const Ref<Texture2D> &p_texture, int p_index) {
|
||||
if (p_texture.is_valid()) {
|
||||
if (!default_textures.has(p_param)) {
|
||||
default_textures[p_param] = HashMap<int, Ref<Texture2D>>();
|
||||
if (!default_textures.has(p_name)) {
|
||||
default_textures[p_name] = HashMap<int, Ref<Texture2D>>();
|
||||
}
|
||||
default_textures[p_param][p_index] = p_texture;
|
||||
RS::get_singleton()->shader_set_default_texture_param(shader, p_param, p_texture->get_rid(), p_index);
|
||||
default_textures[p_name][p_index] = p_texture;
|
||||
RS::get_singleton()->shader_set_default_texture_parameter(shader, p_name, p_texture->get_rid(), p_index);
|
||||
} else {
|
||||
if (default_textures.has(p_param) && default_textures[p_param].has(p_index)) {
|
||||
default_textures[p_param].erase(p_index);
|
||||
if (default_textures.has(p_name) && default_textures[p_name].has(p_index)) {
|
||||
default_textures[p_name].erase(p_index);
|
||||
|
||||
if (default_textures[p_param].is_empty()) {
|
||||
default_textures.erase(p_param);
|
||||
if (default_textures[p_name].is_empty()) {
|
||||
default_textures.erase(p_name);
|
||||
}
|
||||
}
|
||||
RS::get_singleton()->shader_set_default_texture_param(shader, p_param, RID(), p_index);
|
||||
RS::get_singleton()->shader_set_default_texture_parameter(shader, p_name, RID(), p_index);
|
||||
}
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
Ref<Texture2D> Shader::get_default_texture_param(const StringName &p_param, int p_index) const {
|
||||
if (default_textures.has(p_param) && default_textures[p_param].has(p_index)) {
|
||||
return default_textures[p_param][p_index];
|
||||
Ref<Texture2D> Shader::get_default_texture_parameter(const StringName &p_name, int p_index) const {
|
||||
if (default_textures.has(p_name) && default_textures[p_name].has(p_index)) {
|
||||
return default_textures[p_name][p_index];
|
||||
}
|
||||
return Ref<Texture2D>();
|
||||
}
|
||||
|
||||
void Shader::get_default_texture_param_list(List<StringName> *r_textures) const {
|
||||
void Shader::get_default_texture_parameter_list(List<StringName> *r_textures) const {
|
||||
for (const KeyValue<StringName, HashMap<int, Ref<Texture2D>>> &E : default_textures) {
|
||||
r_textures->push_back(E.key);
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ bool Shader::is_text_shader() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Shader::has_uniform(const StringName &p_param) const {
|
||||
return params_cache.has("shader_uniform/" + p_param);
|
||||
bool Shader::has_parameter(const StringName &p_name) const {
|
||||
return params_cache.has("shader_parameter/" + p_name);
|
||||
}
|
||||
|
||||
void Shader::_update_shader() const {
|
||||
|
@ -189,10 +189,10 @@ void Shader::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_code", "code"), &Shader::set_code);
|
||||
ClassDB::bind_method(D_METHOD("get_code"), &Shader::get_code);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_default_texture_param", "param", "texture", "index"), &Shader::set_default_texture_param, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("get_default_texture_param", "param", "index"), &Shader::get_default_texture_param, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("set_default_texture_parameter", "name", "texture", "index"), &Shader::set_default_texture_parameter, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("get_default_texture_parameter", "name", "index"), &Shader::get_default_texture_parameter, DEFVAL(0));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("has_uniform", "name"), &Shader::has_uniform);
|
||||
ClassDB::bind_method(D_METHOD("has_parameter", "name"), &Shader::has_parameter);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "code", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_code", "get_code");
|
||||
|
||||
|
|
|
@ -79,11 +79,11 @@ public:
|
|||
String get_code() const;
|
||||
|
||||
void get_shader_uniform_list(List<PropertyInfo> *p_params, bool p_get_groups = false) const;
|
||||
bool has_uniform(const StringName &p_param) const;
|
||||
bool has_parameter(const StringName &p_name) const;
|
||||
|
||||
void set_default_texture_param(const StringName &p_uniform, const Ref<Texture2D> &p_texture, int p_index = 0);
|
||||
Ref<Texture2D> get_default_texture_param(const StringName &p_uniform, int p_index = 0) const;
|
||||
void get_default_texture_param_list(List<StringName> *r_textures) const;
|
||||
void set_default_texture_parameter(const StringName &p_name, const Ref<Texture2D> &p_texture, int p_index = 0);
|
||||
Ref<Texture2D> get_default_texture_parameter(const StringName &p_name, int p_index = 0) const;
|
||||
void get_default_texture_parameter_list(List<StringName> *r_textures) const;
|
||||
|
||||
virtual bool is_text_shader() const;
|
||||
|
||||
|
|
|
@ -723,10 +723,10 @@ void VisualShader::add_node(Type p_type, const Ref<VisualShaderNode> &p_node, co
|
|||
n.node = p_node;
|
||||
n.position = p_position;
|
||||
|
||||
Ref<VisualShaderNodeUniform> uniform = n.node;
|
||||
if (uniform.is_valid()) {
|
||||
String valid_name = validate_uniform_name(uniform->get_uniform_name(), uniform);
|
||||
uniform->set_uniform_name(valid_name);
|
||||
Ref<VisualShaderNodeParameter> parameter = n.node;
|
||||
if (parameter.is_valid()) {
|
||||
String valid_name = validate_parameter_name(parameter->get_parameter_name(), parameter);
|
||||
parameter->set_parameter_name(valid_name);
|
||||
}
|
||||
|
||||
Ref<VisualShaderNodeInput> input = n.node;
|
||||
|
@ -1279,7 +1279,7 @@ String VisualShader::validate_port_name(const String &p_port_name, VisualShaderN
|
|||
return name;
|
||||
}
|
||||
|
||||
String VisualShader::validate_uniform_name(const String &p_name, const Ref<VisualShaderNodeUniform> &p_uniform) const {
|
||||
String VisualShader::validate_parameter_name(const String &p_name, const Ref<VisualShaderNodeParameter> &p_parameter) const {
|
||||
String name = p_name; //validate name first
|
||||
while (name.length() && !is_ascii_char(name[0])) {
|
||||
name = name.substr(1, name.length() - 1);
|
||||
|
@ -1299,7 +1299,7 @@ String VisualShader::validate_uniform_name(const String &p_name, const Ref<Visua
|
|||
}
|
||||
|
||||
if (name.is_empty()) {
|
||||
name = p_uniform->get_caption();
|
||||
name = p_parameter->get_caption();
|
||||
}
|
||||
|
||||
int attempt = 1;
|
||||
|
@ -1308,11 +1308,11 @@ String VisualShader::validate_uniform_name(const String &p_name, const Ref<Visua
|
|||
bool exists = false;
|
||||
for (int i = 0; i < TYPE_MAX; i++) {
|
||||
for (const KeyValue<int, Node> &E : graph[i].nodes) {
|
||||
Ref<VisualShaderNodeUniform> node = E.value.node;
|
||||
if (node == p_uniform) { //do not test on self
|
||||
Ref<VisualShaderNodeParameter> node = E.value.node;
|
||||
if (node == p_parameter) { //do not test on self
|
||||
continue;
|
||||
}
|
||||
if (node.is_valid() && node->get_uniform_name() == name) {
|
||||
if (node.is_valid() && node->get_parameter_name() == name) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1620,8 +1620,8 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui
|
|||
bool skip_global = input.is_valid() && for_preview;
|
||||
|
||||
if (!skip_global) {
|
||||
Ref<VisualShaderNodeUniform> uniform = vsnode;
|
||||
if (!uniform.is_valid() || !uniform->is_global_code_generated()) {
|
||||
Ref<VisualShaderNodeParameter> parameter = vsnode;
|
||||
if (!parameter.is_valid() || !parameter->is_global_code_generated()) {
|
||||
if (global_code) {
|
||||
*global_code += vsnode->generate_global(get_mode(), type, node);
|
||||
}
|
||||
|
@ -1680,8 +1680,8 @@ Error VisualShader::_write_node(Type type, StringBuilder *global_code, StringBui
|
|||
VisualShaderNode *ptr = const_cast<VisualShaderNode *>(graph[type].nodes[from_node].node.ptr());
|
||||
if (ptr->has_method("get_input_real_name")) {
|
||||
inputs[i] = ptr->call("get_input_real_name");
|
||||
} else if (ptr->has_method("get_uniform_name")) {
|
||||
inputs[i] = ptr->call("get_uniform_name");
|
||||
} else if (ptr->has_method("get_parameter_name")) {
|
||||
inputs[i] = ptr->call("get_parameter_name");
|
||||
} else {
|
||||
inputs[i] = "";
|
||||
}
|
||||
|
@ -2150,8 +2150,8 @@ void VisualShader::_update_shader() const {
|
|||
static const char *func_name[TYPE_MAX] = { "vertex", "fragment", "light", "start", "process", "collide", "start_custom", "process_custom", "sky", "fog" };
|
||||
|
||||
String global_expressions;
|
||||
HashSet<String> used_uniform_names;
|
||||
List<VisualShaderNodeUniform *> uniforms;
|
||||
HashSet<String> used_parameter_names;
|
||||
List<VisualShaderNodeParameter *> parameters;
|
||||
HashMap<int, List<int>> emitters;
|
||||
HashMap<int, List<int>> varying_setters;
|
||||
|
||||
|
@ -2170,13 +2170,13 @@ void VisualShader::_update_shader() const {
|
|||
expr += "\n";
|
||||
global_expressions += expr;
|
||||
}
|
||||
Ref<VisualShaderNodeUniformRef> uniform_ref = E.value.node;
|
||||
if (uniform_ref.is_valid()) {
|
||||
used_uniform_names.insert(uniform_ref->get_uniform_name());
|
||||
Ref<VisualShaderNodeParameterRef> parameter_ref = E.value.node;
|
||||
if (parameter_ref.is_valid()) {
|
||||
used_parameter_names.insert(parameter_ref->get_parameter_name());
|
||||
}
|
||||
Ref<VisualShaderNodeUniform> uniform = E.value.node;
|
||||
if (uniform.is_valid()) {
|
||||
uniforms.push_back(uniform.ptr());
|
||||
Ref<VisualShaderNodeParameter> parameter = E.value.node;
|
||||
if (parameter.is_valid()) {
|
||||
parameters.push_back(parameter.ptr());
|
||||
}
|
||||
Ref<VisualShaderNodeVaryingSetter> varying_setter = E.value.node;
|
||||
if (varying_setter.is_valid() && varying_setter->is_input_port_connected(0)) {
|
||||
|
@ -2195,13 +2195,13 @@ void VisualShader::_update_shader() const {
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < uniforms.size(); i++) {
|
||||
VisualShaderNodeUniform *uniform = uniforms[i];
|
||||
if (used_uniform_names.has(uniform->get_uniform_name())) {
|
||||
global_code += uniform->generate_global(get_mode(), Type(i), -1);
|
||||
const_cast<VisualShaderNodeUniform *>(uniform)->set_global_code_generated(true);
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
VisualShaderNodeParameter *parameter = parameters[i];
|
||||
if (used_parameter_names.has(parameter->get_parameter_name())) {
|
||||
global_code += parameter->generate_global(get_mode(), Type(i), -1);
|
||||
const_cast<VisualShaderNodeParameter *>(parameter)->set_global_code_generated(true);
|
||||
} else {
|
||||
const_cast<VisualShaderNodeUniform *>(uniform)->set_global_code_generated(false);
|
||||
const_cast<VisualShaderNodeParameter *>(parameter)->set_global_code_generated(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2520,7 +2520,7 @@ void VisualShader::_update_shader() const {
|
|||
const_cast<VisualShader *>(this)->set_code(final_code);
|
||||
for (int i = 0; i < default_tex_params.size(); i++) {
|
||||
for (int j = 0; j < default_tex_params[i].params.size(); j++) {
|
||||
const_cast<VisualShader *>(this)->set_default_texture_param(default_tex_params[i].name, default_tex_params[i].params[j], j);
|
||||
const_cast<VisualShader *>(this)->set_default_texture_parameter(default_tex_params[i].name, default_tex_params[i].params[j], j);
|
||||
}
|
||||
}
|
||||
if (previous_code != final_code) {
|
||||
|
@ -3215,20 +3215,20 @@ void VisualShaderNodeInput::_bind_methods() {
|
|||
VisualShaderNodeInput::VisualShaderNodeInput() {
|
||||
}
|
||||
|
||||
////////////// UniformRef
|
||||
////////////// ParameterRef
|
||||
|
||||
RBMap<RID, List<VisualShaderNodeUniformRef::Uniform>> uniforms;
|
||||
RBMap<RID, List<VisualShaderNodeParameterRef::Parameter>> parameters;
|
||||
|
||||
void VisualShaderNodeUniformRef::add_uniform(RID p_shader_rid, const String &p_name, UniformType p_type) {
|
||||
uniforms[p_shader_rid].push_back({ p_name, p_type });
|
||||
void VisualShaderNodeParameterRef::add_parameter(RID p_shader_rid, const String &p_name, ParameterType p_type) {
|
||||
parameters[p_shader_rid].push_back({ p_name, p_type });
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniformRef::clear_uniforms(RID p_shader_rid) {
|
||||
uniforms[p_shader_rid].clear();
|
||||
void VisualShaderNodeParameterRef::clear_parameters(RID p_shader_rid) {
|
||||
parameters[p_shader_rid].clear();
|
||||
}
|
||||
|
||||
bool VisualShaderNodeUniformRef::has_uniform(RID p_shader_rid, const String &p_name) {
|
||||
for (const VisualShaderNodeUniformRef::Uniform &E : uniforms[p_shader_rid]) {
|
||||
bool VisualShaderNodeParameterRef::has_parameter(RID p_shader_rid, const String &p_name) {
|
||||
for (const VisualShaderNodeParameterRef::Parameter &E : parameters[p_shader_rid]) {
|
||||
if (E.name == p_name) {
|
||||
return true;
|
||||
}
|
||||
|
@ -3236,41 +3236,41 @@ bool VisualShaderNodeUniformRef::has_uniform(RID p_shader_rid, const String &p_n
|
|||
return false;
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniformRef::get_caption() const {
|
||||
return "UniformRef";
|
||||
String VisualShaderNodeParameterRef::get_caption() const {
|
||||
return "ParameterRef";
|
||||
}
|
||||
|
||||
int VisualShaderNodeUniformRef::get_input_port_count() const {
|
||||
int VisualShaderNodeParameterRef::get_input_port_count() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
VisualShaderNodeUniformRef::PortType VisualShaderNodeUniformRef::get_input_port_type(int p_port) const {
|
||||
VisualShaderNodeParameterRef::PortType VisualShaderNodeParameterRef::get_input_port_type(int p_port) const {
|
||||
return PortType::PORT_TYPE_SCALAR;
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniformRef::get_input_port_name(int p_port) const {
|
||||
String VisualShaderNodeParameterRef::get_input_port_name(int p_port) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
int VisualShaderNodeUniformRef::get_output_port_count() const {
|
||||
switch (uniform_type) {
|
||||
case UniformType::UNIFORM_TYPE_FLOAT:
|
||||
int VisualShaderNodeParameterRef::get_output_port_count() const {
|
||||
switch (param_type) {
|
||||
case PARAMETER_TYPE_FLOAT:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_INT:
|
||||
case PARAMETER_TYPE_INT:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_BOOLEAN:
|
||||
case PARAMETER_TYPE_BOOLEAN:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR2:
|
||||
case PARAMETER_TYPE_VECTOR2:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR3:
|
||||
case PARAMETER_TYPE_VECTOR3:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR4:
|
||||
case PARAMETER_TYPE_VECTOR4:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_TRANSFORM:
|
||||
case PARAMETER_TYPE_TRANSFORM:
|
||||
return 1;
|
||||
case UniformType::UNIFORM_TYPE_COLOR:
|
||||
case PARAMETER_TYPE_COLOR:
|
||||
return 2;
|
||||
case UniformType::UNIFORM_TYPE_SAMPLER:
|
||||
case UNIFORM_TYPE_SAMPLER:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
|
@ -3278,30 +3278,30 @@ int VisualShaderNodeUniformRef::get_output_port_count() const {
|
|||
return 1;
|
||||
}
|
||||
|
||||
VisualShaderNodeUniformRef::PortType VisualShaderNodeUniformRef::get_output_port_type(int p_port) const {
|
||||
switch (uniform_type) {
|
||||
case UniformType::UNIFORM_TYPE_FLOAT:
|
||||
VisualShaderNodeParameterRef::PortType VisualShaderNodeParameterRef::get_output_port_type(int p_port) const {
|
||||
switch (param_type) {
|
||||
case PARAMETER_TYPE_FLOAT:
|
||||
return PortType::PORT_TYPE_SCALAR;
|
||||
case UniformType::UNIFORM_TYPE_INT:
|
||||
case PARAMETER_TYPE_INT:
|
||||
return PortType::PORT_TYPE_SCALAR_INT;
|
||||
case UniformType::UNIFORM_TYPE_BOOLEAN:
|
||||
case PARAMETER_TYPE_BOOLEAN:
|
||||
return PortType::PORT_TYPE_BOOLEAN;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR2:
|
||||
case PARAMETER_TYPE_VECTOR2:
|
||||
return PortType::PORT_TYPE_VECTOR_2D;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR3:
|
||||
case PARAMETER_TYPE_VECTOR3:
|
||||
return PortType::PORT_TYPE_VECTOR_3D;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR4:
|
||||
case PARAMETER_TYPE_VECTOR4:
|
||||
return PortType::PORT_TYPE_VECTOR_4D;
|
||||
case UniformType::UNIFORM_TYPE_TRANSFORM:
|
||||
case PARAMETER_TYPE_TRANSFORM:
|
||||
return PortType::PORT_TYPE_TRANSFORM;
|
||||
case UniformType::UNIFORM_TYPE_COLOR:
|
||||
case PARAMETER_TYPE_COLOR:
|
||||
if (p_port == 0) {
|
||||
return PortType::PORT_TYPE_VECTOR_3D;
|
||||
} else if (p_port == 1) {
|
||||
return PORT_TYPE_SCALAR;
|
||||
}
|
||||
break;
|
||||
case UniformType::UNIFORM_TYPE_SAMPLER:
|
||||
case UNIFORM_TYPE_SAMPLER:
|
||||
return PortType::PORT_TYPE_SAMPLER;
|
||||
default:
|
||||
break;
|
||||
|
@ -3309,30 +3309,30 @@ VisualShaderNodeUniformRef::PortType VisualShaderNodeUniformRef::get_output_port
|
|||
return PORT_TYPE_SCALAR;
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniformRef::get_output_port_name(int p_port) const {
|
||||
switch (uniform_type) {
|
||||
case UniformType::UNIFORM_TYPE_FLOAT:
|
||||
String VisualShaderNodeParameterRef::get_output_port_name(int p_port) const {
|
||||
switch (param_type) {
|
||||
case PARAMETER_TYPE_FLOAT:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_INT:
|
||||
case PARAMETER_TYPE_INT:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_BOOLEAN:
|
||||
case PARAMETER_TYPE_BOOLEAN:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_VECTOR2:
|
||||
case PARAMETER_TYPE_VECTOR2:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_VECTOR3:
|
||||
case PARAMETER_TYPE_VECTOR3:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_VECTOR4:
|
||||
case PARAMETER_TYPE_VECTOR4:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_TRANSFORM:
|
||||
case PARAMETER_TYPE_TRANSFORM:
|
||||
return "";
|
||||
case UniformType::UNIFORM_TYPE_COLOR:
|
||||
case PARAMETER_TYPE_COLOR:
|
||||
if (p_port == 0) {
|
||||
return "rgb";
|
||||
} else if (p_port == 1) {
|
||||
return "alpha";
|
||||
}
|
||||
break;
|
||||
case UniformType::UNIFORM_TYPE_SAMPLER:
|
||||
case UNIFORM_TYPE_SAMPLER:
|
||||
return "";
|
||||
break;
|
||||
default:
|
||||
|
@ -3341,85 +3341,85 @@ String VisualShaderNodeUniformRef::get_output_port_name(int p_port) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniformRef::set_shader_rid(const RID &p_shader_rid) {
|
||||
void VisualShaderNodeParameterRef::set_shader_rid(const RID &p_shader_rid) {
|
||||
shader_rid = p_shader_rid;
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniformRef::set_uniform_name(const String &p_name) {
|
||||
uniform_name = p_name;
|
||||
void VisualShaderNodeParameterRef::set_parameter_name(const String &p_name) {
|
||||
parameter_name = p_name;
|
||||
if (shader_rid.is_valid()) {
|
||||
update_uniform_type();
|
||||
update_parameter_type();
|
||||
}
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniformRef::update_uniform_type() {
|
||||
if (uniform_name != "[None]") {
|
||||
uniform_type = get_uniform_type_by_name(uniform_name);
|
||||
void VisualShaderNodeParameterRef::update_parameter_type() {
|
||||
if (parameter_name != "[None]") {
|
||||
param_type = get_parameter_type_by_name(parameter_name);
|
||||
} else {
|
||||
uniform_type = UniformType::UNIFORM_TYPE_FLOAT;
|
||||
param_type = PARAMETER_TYPE_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniformRef::get_uniform_name() const {
|
||||
return uniform_name;
|
||||
String VisualShaderNodeParameterRef::get_parameter_name() const {
|
||||
return parameter_name;
|
||||
}
|
||||
|
||||
int VisualShaderNodeUniformRef::get_uniforms_count() const {
|
||||
int VisualShaderNodeParameterRef::get_parameters_count() const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), 0);
|
||||
|
||||
return uniforms[shader_rid].size();
|
||||
return parameters[shader_rid].size();
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniformRef::get_uniform_name_by_index(int p_idx) const {
|
||||
String VisualShaderNodeParameterRef::get_parameter_name_by_index(int p_idx) const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), String());
|
||||
|
||||
if (p_idx >= 0 && p_idx < uniforms[shader_rid].size()) {
|
||||
return uniforms[shader_rid][p_idx].name;
|
||||
if (p_idx >= 0 && p_idx < parameters[shader_rid].size()) {
|
||||
return parameters[shader_rid][p_idx].name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
VisualShaderNodeUniformRef::UniformType VisualShaderNodeUniformRef::get_uniform_type_by_name(const String &p_name) const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), UNIFORM_TYPE_FLOAT);
|
||||
VisualShaderNodeParameterRef::ParameterType VisualShaderNodeParameterRef::get_parameter_type_by_name(const String &p_name) const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), PARAMETER_TYPE_FLOAT);
|
||||
|
||||
for (int i = 0; i < uniforms[shader_rid].size(); i++) {
|
||||
if (uniforms[shader_rid][i].name == p_name) {
|
||||
return uniforms[shader_rid][i].type;
|
||||
for (int i = 0; i < parameters[shader_rid].size(); i++) {
|
||||
if (parameters[shader_rid][i].name == p_name) {
|
||||
return parameters[shader_rid][i].type;
|
||||
}
|
||||
}
|
||||
return UniformType::UNIFORM_TYPE_FLOAT;
|
||||
return PARAMETER_TYPE_FLOAT;
|
||||
}
|
||||
|
||||
VisualShaderNodeUniformRef::UniformType VisualShaderNodeUniformRef::get_uniform_type_by_index(int p_idx) const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), UNIFORM_TYPE_FLOAT);
|
||||
VisualShaderNodeParameterRef::ParameterType VisualShaderNodeParameterRef::get_parameter_type_by_index(int p_idx) const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), PARAMETER_TYPE_FLOAT);
|
||||
|
||||
if (p_idx >= 0 && p_idx < uniforms[shader_rid].size()) {
|
||||
return uniforms[shader_rid][p_idx].type;
|
||||
if (p_idx >= 0 && p_idx < parameters[shader_rid].size()) {
|
||||
return parameters[shader_rid][p_idx].type;
|
||||
}
|
||||
return UniformType::UNIFORM_TYPE_FLOAT;
|
||||
return PARAMETER_TYPE_FLOAT;
|
||||
}
|
||||
|
||||
VisualShaderNodeUniformRef::PortType VisualShaderNodeUniformRef::get_port_type_by_index(int p_idx) const {
|
||||
VisualShaderNodeParameterRef::PortType VisualShaderNodeParameterRef::get_port_type_by_index(int p_idx) const {
|
||||
ERR_FAIL_COND_V(!shader_rid.is_valid(), PORT_TYPE_SCALAR);
|
||||
|
||||
if (p_idx >= 0 && p_idx < uniforms[shader_rid].size()) {
|
||||
switch (uniforms[shader_rid][p_idx].type) {
|
||||
case UniformType::UNIFORM_TYPE_FLOAT:
|
||||
if (p_idx >= 0 && p_idx < parameters[shader_rid].size()) {
|
||||
switch (parameters[shader_rid][p_idx].type) {
|
||||
case PARAMETER_TYPE_FLOAT:
|
||||
return PORT_TYPE_SCALAR;
|
||||
case UniformType::UNIFORM_TYPE_INT:
|
||||
case PARAMETER_TYPE_INT:
|
||||
return PORT_TYPE_SCALAR_INT;
|
||||
case UniformType::UNIFORM_TYPE_SAMPLER:
|
||||
case UNIFORM_TYPE_SAMPLER:
|
||||
return PORT_TYPE_SAMPLER;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR2:
|
||||
case PARAMETER_TYPE_VECTOR2:
|
||||
return PORT_TYPE_VECTOR_2D;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR3:
|
||||
case PARAMETER_TYPE_VECTOR3:
|
||||
return PORT_TYPE_VECTOR_3D;
|
||||
case UniformType::UNIFORM_TYPE_VECTOR4:
|
||||
case PARAMETER_TYPE_VECTOR4:
|
||||
return PORT_TYPE_VECTOR_4D;
|
||||
case UniformType::UNIFORM_TYPE_TRANSFORM:
|
||||
case PARAMETER_TYPE_TRANSFORM:
|
||||
return PORT_TYPE_TRANSFORM;
|
||||
case UniformType::UNIFORM_TYPE_COLOR:
|
||||
case PARAMETER_TYPE_COLOR:
|
||||
return PORT_TYPE_VECTOR_3D;
|
||||
default:
|
||||
break;
|
||||
|
@ -3428,54 +3428,54 @@ VisualShaderNodeUniformRef::PortType VisualShaderNodeUniformRef::get_port_type_b
|
|||
return PORT_TYPE_SCALAR;
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniformRef::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||
switch (uniform_type) {
|
||||
case UniformType::UNIFORM_TYPE_FLOAT:
|
||||
if (uniform_name == "[None]") {
|
||||
String VisualShaderNodeParameterRef::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
|
||||
switch (param_type) {
|
||||
case PARAMETER_TYPE_FLOAT:
|
||||
if (parameter_name == "[None]") {
|
||||
return " " + p_output_vars[0] + " = 0.0;\n";
|
||||
}
|
||||
break;
|
||||
case UniformType::UNIFORM_TYPE_COLOR: {
|
||||
String code = " " + p_output_vars[0] + " = " + get_uniform_name() + ".rgb;\n";
|
||||
code += " " + p_output_vars[1] + " = " + get_uniform_name() + ".a;\n";
|
||||
case PARAMETER_TYPE_COLOR: {
|
||||
String code = " " + p_output_vars[0] + " = " + get_parameter_name() + ".rgb;\n";
|
||||
code += " " + p_output_vars[1] + " = " + get_parameter_name() + ".a;\n";
|
||||
return code;
|
||||
} break;
|
||||
case UniformType::UNIFORM_TYPE_SAMPLER:
|
||||
case UNIFORM_TYPE_SAMPLER:
|
||||
return String();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return " " + p_output_vars[0] + " = " + get_uniform_name() + ";\n";
|
||||
return " " + p_output_vars[0] + " = " + get_parameter_name() + ";\n";
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniformRef::_set_uniform_type(int p_uniform_type) {
|
||||
uniform_type = (UniformType)p_uniform_type;
|
||||
void VisualShaderNodeParameterRef::_set_parameter_type(int p_type) {
|
||||
param_type = (ParameterType)p_type;
|
||||
}
|
||||
|
||||
int VisualShaderNodeUniformRef::_get_uniform_type() const {
|
||||
return (int)uniform_type;
|
||||
int VisualShaderNodeParameterRef::_get_parameter_type() const {
|
||||
return (int)param_type;
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniformRef::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_uniform_name", "name"), &VisualShaderNodeUniformRef::set_uniform_name);
|
||||
ClassDB::bind_method(D_METHOD("get_uniform_name"), &VisualShaderNodeUniformRef::get_uniform_name);
|
||||
void VisualShaderNodeParameterRef::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_parameter_name", "name"), &VisualShaderNodeParameterRef::set_parameter_name);
|
||||
ClassDB::bind_method(D_METHOD("get_parameter_name"), &VisualShaderNodeParameterRef::get_parameter_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_set_uniform_type", "type"), &VisualShaderNodeUniformRef::_set_uniform_type);
|
||||
ClassDB::bind_method(D_METHOD("_get_uniform_type"), &VisualShaderNodeUniformRef::_get_uniform_type);
|
||||
ClassDB::bind_method(D_METHOD("_set_parameter_type", "type"), &VisualShaderNodeParameterRef::_set_parameter_type);
|
||||
ClassDB::bind_method(D_METHOD("_get_parameter_type"), &VisualShaderNodeParameterRef::_get_parameter_type);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "uniform_name", PROPERTY_HINT_ENUM, ""), "set_uniform_name", "get_uniform_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "uniform_type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_uniform_type", "_get_uniform_type");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "parameter_name", PROPERTY_HINT_ENUM, ""), "set_parameter_name", "get_parameter_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "param_type", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL), "_set_parameter_type", "_get_parameter_type");
|
||||
}
|
||||
|
||||
Vector<StringName> VisualShaderNodeUniformRef::get_editable_properties() const {
|
||||
Vector<StringName> VisualShaderNodeParameterRef::get_editable_properties() const {
|
||||
Vector<StringName> props;
|
||||
props.push_back("uniform_name");
|
||||
props.push_back("uniform_type");
|
||||
props.push_back("parameter_name");
|
||||
props.push_back("param_type");
|
||||
return props;
|
||||
}
|
||||
|
||||
VisualShaderNodeUniformRef::VisualShaderNodeUniformRef() {
|
||||
VisualShaderNodeParameterRef::VisualShaderNodeParameterRef() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
|
@ -3687,17 +3687,17 @@ VisualShaderNodeOutput::VisualShaderNodeOutput() {
|
|||
|
||||
///////////////////////////
|
||||
|
||||
void VisualShaderNodeUniform::set_uniform_name(const String &p_name) {
|
||||
uniform_name = p_name;
|
||||
void VisualShaderNodeParameter::set_parameter_name(const String &p_name) {
|
||||
parameter_name = p_name;
|
||||
emit_signal(SNAME("name_changed"));
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniform::get_uniform_name() const {
|
||||
return uniform_name;
|
||||
String VisualShaderNodeParameter::get_parameter_name() const {
|
||||
return parameter_name;
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniform::set_qualifier(VisualShaderNodeUniform::Qualifier p_qual) {
|
||||
void VisualShaderNodeParameter::set_qualifier(VisualShaderNodeParameter::Qualifier p_qual) {
|
||||
ERR_FAIL_INDEX(int(p_qual), int(QUAL_MAX));
|
||||
if (qualifier == p_qual) {
|
||||
return;
|
||||
|
@ -3706,26 +3706,26 @@ void VisualShaderNodeUniform::set_qualifier(VisualShaderNodeUniform::Qualifier p
|
|||
emit_changed();
|
||||
}
|
||||
|
||||
VisualShaderNodeUniform::Qualifier VisualShaderNodeUniform::get_qualifier() const {
|
||||
VisualShaderNodeParameter::Qualifier VisualShaderNodeParameter::get_qualifier() const {
|
||||
return qualifier;
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniform::set_global_code_generated(bool p_enabled) {
|
||||
void VisualShaderNodeParameter::set_global_code_generated(bool p_enabled) {
|
||||
global_code_generated = p_enabled;
|
||||
}
|
||||
|
||||
bool VisualShaderNodeUniform::is_global_code_generated() const {
|
||||
bool VisualShaderNodeParameter::is_global_code_generated() const {
|
||||
return global_code_generated;
|
||||
}
|
||||
|
||||
void VisualShaderNodeUniform::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_uniform_name", "name"), &VisualShaderNodeUniform::set_uniform_name);
|
||||
ClassDB::bind_method(D_METHOD("get_uniform_name"), &VisualShaderNodeUniform::get_uniform_name);
|
||||
void VisualShaderNodeParameter::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_parameter_name", "name"), &VisualShaderNodeParameter::set_parameter_name);
|
||||
ClassDB::bind_method(D_METHOD("get_parameter_name"), &VisualShaderNodeParameter::get_parameter_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_qualifier", "qualifier"), &VisualShaderNodeUniform::set_qualifier);
|
||||
ClassDB::bind_method(D_METHOD("get_qualifier"), &VisualShaderNodeUniform::get_qualifier);
|
||||
ClassDB::bind_method(D_METHOD("set_qualifier", "qualifier"), &VisualShaderNodeParameter::set_qualifier);
|
||||
ClassDB::bind_method(D_METHOD("get_qualifier"), &VisualShaderNodeParameter::get_qualifier);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "uniform_name"), "set_uniform_name", "get_uniform_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "parameter_name"), "set_parameter_name", "get_parameter_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "qualifier", PROPERTY_HINT_ENUM, "None,Global,Instance"), "set_qualifier", "get_qualifier");
|
||||
|
||||
BIND_ENUM_CONSTANT(QUAL_NONE);
|
||||
|
@ -3734,7 +3734,7 @@ void VisualShaderNodeUniform::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(QUAL_MAX);
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniform::_get_qual_str() const {
|
||||
String VisualShaderNodeParameter::_get_qual_str() const {
|
||||
if (is_qualifier_supported(qualifier)) {
|
||||
switch (qualifier) {
|
||||
case QUAL_NONE:
|
||||
|
@ -3750,11 +3750,11 @@ String VisualShaderNodeUniform::_get_qual_str() const {
|
|||
return String();
|
||||
}
|
||||
|
||||
String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const {
|
||||
String VisualShaderNodeParameter::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const {
|
||||
List<String> keyword_list;
|
||||
ShaderLanguage::get_keyword_list(&keyword_list);
|
||||
if (keyword_list.find(uniform_name)) {
|
||||
return RTR("Shader keywords cannot be used as uniform names.\nChoose another name.");
|
||||
if (keyword_list.find(parameter_name)) {
|
||||
return RTR("Shader keywords cannot be used as parameter names.\nChoose another name.");
|
||||
}
|
||||
if (!is_qualifier_supported(qualifier)) {
|
||||
String qualifier_str;
|
||||
|
@ -3770,66 +3770,66 @@ String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::T
|
|||
default:
|
||||
break;
|
||||
}
|
||||
return vformat(RTR("This uniform type does not support the '%s' qualifier."), qualifier_str);
|
||||
return vformat(RTR("This parameter type does not support the '%s' qualifier."), qualifier_str);
|
||||
} else if (qualifier == Qualifier::QUAL_GLOBAL) {
|
||||
RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(uniform_name);
|
||||
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(parameter_name);
|
||||
if (gvt == RS::GLOBAL_VAR_TYPE_MAX) {
|
||||
return vformat(RTR("Global uniform '%s' does not exist.\nCreate it in the Project Settings."), uniform_name);
|
||||
return vformat(RTR("Global parameter '%s' does not exist.\nCreate it in the Project Settings."), parameter_name);
|
||||
}
|
||||
bool incompatible_type = false;
|
||||
switch (gvt) {
|
||||
case RS::GLOBAL_VAR_TYPE_FLOAT: {
|
||||
if (!Object::cast_to<VisualShaderNodeFloatUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeFloatParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_INT: {
|
||||
if (!Object::cast_to<VisualShaderNodeIntUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeIntParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
if (!Object::cast_to<VisualShaderNodeBooleanUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeBooleanParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_COLOR: {
|
||||
if (!Object::cast_to<VisualShaderNodeColorUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeColorParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_VEC3: {
|
||||
if (!Object::cast_to<VisualShaderNodeVec3Uniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeVec3Parameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_VEC4: {
|
||||
if (!Object::cast_to<VisualShaderNodeVec4Uniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeVec4Parameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_TRANSFORM: {
|
||||
if (!Object::cast_to<VisualShaderNodeTransformUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeTransformParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLER2D: {
|
||||
if (!Object::cast_to<VisualShaderNodeTextureUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeTextureParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLER3D: {
|
||||
if (!Object::cast_to<VisualShaderNodeTexture3DUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeTexture3DParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLER2DARRAY: {
|
||||
if (!Object::cast_to<VisualShaderNodeTexture2DArrayUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeTexture2DArrayParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
case RS::GLOBAL_VAR_TYPE_SAMPLERCUBE: {
|
||||
if (!Object::cast_to<VisualShaderNodeCubemapUniform>(this)) {
|
||||
if (!Object::cast_to<VisualShaderNodeCubemapParameter>(this)) {
|
||||
incompatible_type = true;
|
||||
}
|
||||
} break;
|
||||
|
@ -3837,20 +3837,20 @@ String VisualShaderNodeUniform::get_warning(Shader::Mode p_mode, VisualShader::T
|
|||
break;
|
||||
}
|
||||
if (incompatible_type) {
|
||||
return vformat(RTR("Global uniform '%s' has an incompatible type for this kind of node.\nChange it in the Project Settings."), uniform_name);
|
||||
return vformat(RTR("Global parameter '%s' has an incompatible type for this kind of node.\nChange it in the Project Settings."), parameter_name);
|
||||
}
|
||||
}
|
||||
|
||||
return String();
|
||||
}
|
||||
|
||||
Vector<StringName> VisualShaderNodeUniform::get_editable_properties() const {
|
||||
Vector<StringName> VisualShaderNodeParameter::get_editable_properties() const {
|
||||
Vector<StringName> props;
|
||||
props.push_back("qualifier");
|
||||
return props;
|
||||
}
|
||||
|
||||
VisualShaderNodeUniform::VisualShaderNodeUniform() {
|
||||
VisualShaderNodeParameter::VisualShaderNodeParameter() {
|
||||
}
|
||||
|
||||
////////////// ResizeableBase
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "scene/gui/control.h"
|
||||
#include "scene/resources/shader.h"
|
||||
|
||||
class VisualShaderNodeUniform;
|
||||
class VisualShaderNodeParameter;
|
||||
class VisualShaderNode;
|
||||
|
||||
class VisualShader : public Shader {
|
||||
|
@ -229,7 +229,7 @@ public: // internal methods
|
|||
String generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &r_default_tex_params) const;
|
||||
|
||||
String validate_port_name(const String &p_port_name, VisualShaderNode *p_node, int p_port_id, bool p_output) const;
|
||||
String validate_uniform_name(const String &p_name, const Ref<VisualShaderNodeUniform> &p_uniform) const;
|
||||
String validate_parameter_name(const String &p_name, const Ref<VisualShaderNodeParameter> &p_parameter) const;
|
||||
|
||||
VisualShader();
|
||||
};
|
||||
|
@ -499,8 +499,8 @@ public:
|
|||
VisualShaderNodeOutput();
|
||||
};
|
||||
|
||||
class VisualShaderNodeUniform : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeUniform, VisualShaderNode);
|
||||
class VisualShaderNodeParameter : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeParameter, VisualShaderNode);
|
||||
|
||||
public:
|
||||
enum Qualifier {
|
||||
|
@ -511,7 +511,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
String uniform_name = "";
|
||||
String parameter_name = "";
|
||||
Qualifier qualifier = QUAL_NONE;
|
||||
bool global_code_generated = false;
|
||||
|
||||
|
@ -520,8 +520,8 @@ protected:
|
|||
String _get_qual_str() const;
|
||||
|
||||
public:
|
||||
void set_uniform_name(const String &p_name);
|
||||
String get_uniform_name() const;
|
||||
void set_parameter_name(const String &p_name);
|
||||
String get_parameter_name() const;
|
||||
|
||||
void set_qualifier(Qualifier p_qual);
|
||||
Qualifier get_qualifier() const;
|
||||
|
@ -535,44 +535,44 @@ public:
|
|||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override;
|
||||
|
||||
VisualShaderNodeUniform();
|
||||
VisualShaderNodeParameter();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeUniform::Qualifier)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeParameter::Qualifier)
|
||||
|
||||
class VisualShaderNodeUniformRef : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeUniformRef, VisualShaderNode);
|
||||
class VisualShaderNodeParameterRef : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeParameterRef, VisualShaderNode);
|
||||
|
||||
public:
|
||||
enum UniformType {
|
||||
UNIFORM_TYPE_FLOAT,
|
||||
UNIFORM_TYPE_INT,
|
||||
UNIFORM_TYPE_BOOLEAN,
|
||||
UNIFORM_TYPE_VECTOR2,
|
||||
UNIFORM_TYPE_VECTOR3,
|
||||
UNIFORM_TYPE_VECTOR4,
|
||||
UNIFORM_TYPE_TRANSFORM,
|
||||
UNIFORM_TYPE_COLOR,
|
||||
enum ParameterType {
|
||||
PARAMETER_TYPE_FLOAT,
|
||||
PARAMETER_TYPE_INT,
|
||||
PARAMETER_TYPE_BOOLEAN,
|
||||
PARAMETER_TYPE_VECTOR2,
|
||||
PARAMETER_TYPE_VECTOR3,
|
||||
PARAMETER_TYPE_VECTOR4,
|
||||
PARAMETER_TYPE_TRANSFORM,
|
||||
PARAMETER_TYPE_COLOR,
|
||||
UNIFORM_TYPE_SAMPLER,
|
||||
};
|
||||
|
||||
struct Uniform {
|
||||
struct Parameter {
|
||||
String name;
|
||||
UniformType type;
|
||||
ParameterType type;
|
||||
};
|
||||
|
||||
private:
|
||||
RID shader_rid;
|
||||
String uniform_name = "[None]";
|
||||
UniformType uniform_type = UniformType::UNIFORM_TYPE_FLOAT;
|
||||
String parameter_name = "[None]";
|
||||
ParameterType param_type = ParameterType::PARAMETER_TYPE_FLOAT;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static void add_uniform(RID p_shader_rid, const String &p_name, UniformType p_type);
|
||||
static void clear_uniforms(RID p_shader_rid);
|
||||
static bool has_uniform(RID p_shader_rid, const String &p_name);
|
||||
static void add_parameter(RID p_shader_rid, const String &p_name, ParameterType p_type);
|
||||
static void clear_parameters(RID p_shader_rid);
|
||||
static bool has_parameter(RID p_shader_rid, const String &p_name);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
|
@ -587,25 +587,25 @@ public:
|
|||
|
||||
void set_shader_rid(const RID &p_shader);
|
||||
|
||||
void set_uniform_name(const String &p_name);
|
||||
String get_uniform_name() const;
|
||||
void set_parameter_name(const String &p_name);
|
||||
String get_parameter_name() const;
|
||||
|
||||
void update_uniform_type();
|
||||
void update_parameter_type();
|
||||
|
||||
void _set_uniform_type(int p_uniform_type);
|
||||
int _get_uniform_type() const;
|
||||
void _set_parameter_type(int p_parameter_type);
|
||||
int _get_parameter_type() const;
|
||||
|
||||
int get_uniforms_count() const;
|
||||
String get_uniform_name_by_index(int p_idx) const;
|
||||
UniformType get_uniform_type_by_name(const String &p_name) const;
|
||||
UniformType get_uniform_type_by_index(int p_idx) const;
|
||||
int get_parameters_count() const;
|
||||
String get_parameter_name_by_index(int p_idx) const;
|
||||
ParameterType get_parameter_type_by_name(const String &p_name) const;
|
||||
ParameterType get_parameter_type_by_index(int p_idx) const;
|
||||
PortType get_port_type_by_index(int p_idx) const;
|
||||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
|
||||
|
||||
VisualShaderNodeUniformRef();
|
||||
VisualShaderNodeParameterRef();
|
||||
};
|
||||
|
||||
class VisualShaderNodeResizableBase : public VisualShaderNode {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1762,11 +1762,11 @@ public:
|
|||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
/// UNIFORMS
|
||||
/// PARAMETERS
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeFloatUniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeFloatUniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeFloatParameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeFloatParameter, VisualShaderNodeParameter);
|
||||
|
||||
public:
|
||||
enum Hint {
|
||||
|
@ -1827,13 +1827,13 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeFloatUniform();
|
||||
VisualShaderNodeFloatParameter();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeFloatUniform::Hint)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeFloatParameter::Hint)
|
||||
|
||||
class VisualShaderNodeIntUniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeIntUniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeIntParameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeIntParameter, VisualShaderNodeParameter);
|
||||
|
||||
public:
|
||||
enum Hint {
|
||||
|
@ -1894,15 +1894,15 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeIntUniform();
|
||||
VisualShaderNodeIntParameter();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeIntUniform::Hint)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeIntParameter::Hint)
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeBooleanUniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeBooleanUniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeBooleanParameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeBooleanParameter, VisualShaderNodeParameter);
|
||||
|
||||
private:
|
||||
bool default_value_enabled = false;
|
||||
|
@ -1939,13 +1939,13 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeBooleanUniform();
|
||||
VisualShaderNodeBooleanParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeColorUniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeColorUniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeColorParameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeColorParameter, VisualShaderNodeParameter);
|
||||
|
||||
private:
|
||||
bool default_value_enabled = false;
|
||||
|
@ -1983,13 +1983,13 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeColorUniform();
|
||||
VisualShaderNodeColorParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeVec2Uniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeVec2Uniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeVec2Parameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeVec2Parameter, VisualShaderNodeParameter);
|
||||
|
||||
private:
|
||||
bool default_value_enabled = false;
|
||||
|
@ -2026,13 +2026,13 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeVec2Uniform();
|
||||
VisualShaderNodeVec2Parameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeVec3Uniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeVec3Uniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeVec3Parameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeVec3Parameter, VisualShaderNodeParameter);
|
||||
|
||||
private:
|
||||
bool default_value_enabled = false;
|
||||
|
@ -2069,17 +2069,17 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeVec3Uniform();
|
||||
VisualShaderNodeVec3Parameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeVec4Uniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeVec4Uniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeVec4Parameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeVec4Parameter, VisualShaderNodeParameter);
|
||||
|
||||
private:
|
||||
bool default_value_enabled = false;
|
||||
Quaternion default_value;
|
||||
Vector4 default_value;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -2104,21 +2104,21 @@ public:
|
|||
void set_default_value_enabled(bool p_enabled);
|
||||
bool is_default_value_enabled() const;
|
||||
|
||||
void set_default_value(const Quaternion &p_value);
|
||||
Quaternion get_default_value() const;
|
||||
void set_default_value(const Vector4 &p_value);
|
||||
Vector4 get_default_value() const;
|
||||
|
||||
bool is_qualifier_supported(Qualifier p_qual) const override;
|
||||
bool is_convertible_to_constant() const override;
|
||||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeVec4Uniform();
|
||||
VisualShaderNodeVec4Parameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeTransformUniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeTransformUniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeTransformParameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeTransformParameter, VisualShaderNodeParameter);
|
||||
|
||||
private:
|
||||
bool default_value_enabled = false;
|
||||
|
@ -2155,13 +2155,13 @@ public:
|
|||
|
||||
virtual Vector<StringName> get_editable_properties() const override;
|
||||
|
||||
VisualShaderNodeTransformUniform();
|
||||
VisualShaderNodeTransformParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeTextureUniform : public VisualShaderNodeUniform {
|
||||
GDCLASS(VisualShaderNodeTextureUniform, VisualShaderNodeUniform);
|
||||
class VisualShaderNodeTextureParameter : public VisualShaderNodeParameter {
|
||||
GDCLASS(VisualShaderNodeTextureParameter, VisualShaderNodeParameter);
|
||||
|
||||
public:
|
||||
enum TextureType {
|
||||
|
@ -2207,17 +2207,13 @@ protected:
|
|||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
|
||||
virtual int get_input_port_count() const override;
|
||||
virtual PortType get_input_port_type(int p_port) const override;
|
||||
virtual String get_input_port_name(int p_port) const override;
|
||||
|
||||
virtual int get_output_port_count() const override;
|
||||
virtual PortType get_output_port_type(int p_port) const override;
|
||||
virtual String get_output_port_name(int p_port) const override;
|
||||
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
|
||||
|
||||
virtual HashMap<StringName, String> get_editable_properties_names() const override;
|
||||
|
@ -2240,18 +2236,32 @@ public:
|
|||
bool is_qualifier_supported(Qualifier p_qual) const override;
|
||||
bool is_convertible_to_constant() const override;
|
||||
|
||||
VisualShaderNodeTextureUniform();
|
||||
VisualShaderNodeTextureParameter();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureUniform::TextureType)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureUniform::ColorDefault)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureUniform::TextureFilter)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureUniform::TextureRepeat)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureType)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::ColorDefault)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureFilter)
|
||||
VARIANT_ENUM_CAST(VisualShaderNodeTextureParameter::TextureRepeat)
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeTextureUniformTriplanar : public VisualShaderNodeTextureUniform {
|
||||
GDCLASS(VisualShaderNodeTextureUniformTriplanar, VisualShaderNodeTextureUniform);
|
||||
class VisualShaderNodeTexture2DParameter : public VisualShaderNodeTextureParameter {
|
||||
GDCLASS(VisualShaderNodeTexture2DParameter, VisualShaderNodeTextureParameter);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
virtual String get_output_port_name(int p_port) const override;
|
||||
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
|
||||
|
||||
VisualShaderNodeTexture2DParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeTextureParameterTriplanar : public VisualShaderNodeTextureParameter {
|
||||
GDCLASS(VisualShaderNodeTextureParameterTriplanar, VisualShaderNodeTextureParameter);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
|
@ -2270,52 +2280,49 @@ public:
|
|||
virtual String generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
|
||||
|
||||
VisualShaderNodeTextureUniformTriplanar();
|
||||
VisualShaderNodeTextureParameterTriplanar();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeTexture2DArrayUniform : public VisualShaderNodeTextureUniform {
|
||||
GDCLASS(VisualShaderNodeTexture2DArrayUniform, VisualShaderNodeTextureUniform);
|
||||
class VisualShaderNodeTexture2DArrayParameter : public VisualShaderNodeTextureParameter {
|
||||
GDCLASS(VisualShaderNodeTexture2DArrayParameter, VisualShaderNodeTextureParameter);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
virtual String get_output_port_name(int p_port) const override;
|
||||
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
|
||||
|
||||
VisualShaderNodeTexture2DArrayUniform();
|
||||
VisualShaderNodeTexture2DArrayParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeTexture3DUniform : public VisualShaderNodeTextureUniform {
|
||||
GDCLASS(VisualShaderNodeTexture3DUniform, VisualShaderNodeTextureUniform);
|
||||
class VisualShaderNodeTexture3DParameter : public VisualShaderNodeTextureParameter {
|
||||
GDCLASS(VisualShaderNodeTexture3DParameter, VisualShaderNodeTextureParameter);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
virtual String get_output_port_name(int p_port) const override;
|
||||
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
|
||||
|
||||
VisualShaderNodeTexture3DUniform();
|
||||
VisualShaderNodeTexture3DParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
class VisualShaderNodeCubemapUniform : public VisualShaderNodeTextureUniform {
|
||||
GDCLASS(VisualShaderNodeCubemapUniform, VisualShaderNodeTextureUniform);
|
||||
class VisualShaderNodeCubemapParameter : public VisualShaderNodeTextureParameter {
|
||||
GDCLASS(VisualShaderNodeCubemapParameter, VisualShaderNodeTextureParameter);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const override;
|
||||
virtual String get_output_port_name(int p_port) const override;
|
||||
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override;
|
||||
|
||||
VisualShaderNodeCubemapUniform();
|
||||
VisualShaderNodeCubemapParameter();
|
||||
};
|
||||
|
||||
///////////////////////////////////////
|
||||
|
|
|
@ -40,21 +40,21 @@ class MaterialStorage : public RendererMaterialStorage {
|
|||
public:
|
||||
/* GLOBAL SHADER UNIFORM API */
|
||||
|
||||
virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) override {}
|
||||
virtual void global_shader_uniform_remove(const StringName &p_name) override {}
|
||||
virtual Vector<StringName> global_shader_uniform_get_list() const override { return Vector<StringName>(); }
|
||||
virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override {}
|
||||
virtual void global_shader_parameter_remove(const StringName &p_name) override {}
|
||||
virtual Vector<StringName> global_shader_parameter_get_list() const override { return Vector<StringName>(); }
|
||||
|
||||
virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) override {}
|
||||
virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) override {}
|
||||
virtual Variant global_shader_uniform_get(const StringName &p_name) const override { return Variant(); }
|
||||
virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const override { return RS::GLOBAL_VAR_TYPE_MAX; }
|
||||
virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override {}
|
||||
virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override {}
|
||||
virtual Variant global_shader_parameter_get(const StringName &p_name) const override { return Variant(); }
|
||||
virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override { return RS::GLOBAL_VAR_TYPE_MAX; }
|
||||
|
||||
virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) override {}
|
||||
virtual void global_shader_uniforms_clear() override {}
|
||||
virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override {}
|
||||
virtual void global_shader_parameters_clear() override {}
|
||||
|
||||
virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) override { return 0; }
|
||||
virtual void global_shader_uniforms_instance_free(RID p_instance) override {}
|
||||
virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) override {}
|
||||
virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override { return 0; }
|
||||
virtual void global_shader_parameters_instance_free(RID p_instance) override {}
|
||||
virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) override {}
|
||||
|
||||
/* SHADER API */
|
||||
|
||||
|
@ -66,11 +66,11 @@ public:
|
|||
virtual void shader_set_path_hint(RID p_shader, const String &p_code) override {}
|
||||
|
||||
virtual String shader_get_code(RID p_shader) const override { return ""; }
|
||||
virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const override {}
|
||||
virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const override {}
|
||||
|
||||
virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override {}
|
||||
virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const override { return RID(); }
|
||||
virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const override { return Variant(); }
|
||||
virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override {}
|
||||
virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override { return RID(); }
|
||||
virtual Variant shader_get_parameter_default(RID p_material, const StringName &p_param) const override { return Variant(); }
|
||||
|
||||
virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override { return RS::ShaderNativeSourceCode(); };
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
|
||||
virtual bool material_is_animated(RID p_material) override { return false; }
|
||||
virtual bool material_casts_shadows(RID p_material) override { return false; }
|
||||
virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) override {}
|
||||
virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override {}
|
||||
virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) override {}
|
||||
};
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ void Fog::FogShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void Fog::FogShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void Fog::FogShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -430,7 +430,7 @@ void Fog::FogShaderData::get_instance_param_list(List<RendererMaterialStorage::I
|
|||
}
|
||||
}
|
||||
|
||||
bool Fog::FogShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool Fog::FogShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -199,10 +199,10 @@ private:
|
|||
|
||||
virtual void set_path_hint(const String &p_hint);
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
|
|
@ -151,7 +151,7 @@ void SkyRD::SkyShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void SkyRD::SkyShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void SkyRD::SkyShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -219,7 +219,7 @@ void SkyRD::SkyShaderData::get_instance_param_list(List<RendererMaterialStorage:
|
|||
}
|
||||
}
|
||||
|
||||
bool SkyRD::SkyShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool SkyRD::SkyShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -130,10 +130,10 @@ private:
|
|||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_path_hint(const String &p_hint);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
|
|
@ -375,7 +375,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void SceneShaderForwardClustered::ShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void SceneShaderForwardClustered::ShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -448,7 +448,7 @@ void SceneShaderForwardClustered::ShaderData::get_instance_param_list(List<Rende
|
|||
}
|
||||
}
|
||||
|
||||
bool SceneShaderForwardClustered::ShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool SceneShaderForwardClustered::ShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -182,11 +182,11 @@ public:
|
|||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_path_hint(const String &p_path);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
|
|
@ -331,7 +331,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void SceneShaderForwardMobile::ShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void SceneShaderForwardMobile::ShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -403,7 +403,7 @@ void SceneShaderForwardMobile::ShaderData::get_instance_param_list(List<Renderer
|
|||
}
|
||||
}
|
||||
|
||||
bool SceneShaderForwardMobile::ShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool SceneShaderForwardMobile::ShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -141,11 +141,11 @@ public:
|
|||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_path_hint(const String &p_path);
|
||||
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
|
|
@ -2192,7 +2192,7 @@ void RendererCanvasRenderRD::CanvasShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void RendererCanvasRenderRD::CanvasShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void RendererCanvasRenderRD::CanvasShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -2264,7 +2264,7 @@ void RendererCanvasRenderRD::CanvasShaderData::get_instance_param_list(List<Rend
|
|||
}
|
||||
}
|
||||
|
||||
bool RendererCanvasRenderRD::CanvasShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool RendererCanvasRenderRD::CanvasShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -182,11 +182,11 @@ class RendererCanvasRenderRD : public RendererCanvasRender {
|
|||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_path_hint(const String &p_path);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
|
|
@ -954,7 +954,7 @@ void MaterialStorage::MaterialData::update_uniform_buffer(const HashMap<StringNa
|
|||
if (gv) {
|
||||
index = gv->buffer_index;
|
||||
} else {
|
||||
WARN_PRINT("Shader uses global uniform '" + E.key + "', but it was removed at some point. Material will not display correctly.");
|
||||
WARN_PRINT("Shader uses global parameter '" + E.key + "', but it was removed at some point. Material will not display correctly.");
|
||||
}
|
||||
|
||||
uint32_t offset = p_uniform_offsets[E.value.order];
|
||||
|
@ -1070,7 +1070,7 @@ void MaterialStorage::MaterialData::update_textures(const HashMap<StringName, Va
|
|||
GlobalShaderUniforms::Variable *v = material_storage->global_shader_uniforms.variables.getptr(uniform_name);
|
||||
if (v) {
|
||||
if (v->buffer_index >= 0) {
|
||||
WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!.");
|
||||
WARN_PRINT("Shader uses global parameter texture '" + String(uniform_name) + "', but it changed type and is no longer a texture!.");
|
||||
|
||||
} else {
|
||||
HashMap<StringName, uint64_t>::Iterator E = used_global_textures.find(uniform_name);
|
||||
|
@ -1085,7 +1085,7 @@ void MaterialStorage::MaterialData::update_textures(const HashMap<StringName, Va
|
|||
}
|
||||
|
||||
} else {
|
||||
WARN_PRINT("Shader uses global uniform texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly.");
|
||||
WARN_PRINT("Shader uses global parameter texture '" + String(uniform_name) + "', but it was removed at some point. Material will not display correctly.");
|
||||
}
|
||||
} else {
|
||||
HashMap<StringName, Variant>::ConstIterator V = p_parameters.find(uniform_name);
|
||||
|
@ -1652,7 +1652,7 @@ int32_t MaterialStorage::_global_shader_uniform_allocate(uint32_t p_elements) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value) {
|
||||
void MaterialStorage::_global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value) {
|
||||
switch (p_type) {
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL: {
|
||||
GlobalShaderUniforms::Value &bv = global_shader_uniforms.buffer_values[p_index];
|
||||
|
@ -1945,7 +1945,7 @@ void MaterialStorage::_global_shader_uniform_mark_buffer_dirty(int32_t p_index,
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) {
|
||||
ERR_FAIL_COND(global_shader_uniforms.variables.has(p_name));
|
||||
GlobalShaderUniforms::Variable gv;
|
||||
gv.type = p_type;
|
||||
|
@ -1983,7 +1983,7 @@ void MaterialStorage::global_shader_uniform_add(const StringName &p_name, RS::Gl
|
|||
global_shader_uniforms.variables[p_name] = gv;
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_remove(const StringName &p_name) {
|
||||
void MaterialStorage::global_shader_parameter_remove(const StringName &p_name) {
|
||||
if (!global_shader_uniforms.variables.has(p_name)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1999,7 +1999,7 @@ void MaterialStorage::global_shader_uniform_remove(const StringName &p_name) {
|
|||
global_shader_uniforms.variables.erase(p_name);
|
||||
}
|
||||
|
||||
Vector<StringName> MaterialStorage::global_shader_uniform_get_list() const {
|
||||
Vector<StringName> MaterialStorage::global_shader_parameter_get_list() const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_V_MSG(Vector<StringName>(), "This function should never be used outside the editor, it can severely damage performance.");
|
||||
}
|
||||
|
@ -2012,7 +2012,7 @@ Vector<StringName> MaterialStorage::global_shader_uniform_get_list() const {
|
|||
return names;
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_set(const StringName &p_name, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameter_set(const StringName &p_name, const Variant &p_value) {
|
||||
ERR_FAIL_COND(!global_shader_uniforms.variables.has(p_name));
|
||||
GlobalShaderUniforms::Variable &gv = global_shader_uniforms.variables[p_name];
|
||||
gv.value = p_value;
|
||||
|
@ -2033,7 +2033,7 @@ void MaterialStorage::global_shader_uniform_set(const StringName &p_name, const
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) {
|
||||
if (!global_shader_uniforms.variables.has(p_name)) {
|
||||
return; //variable may not exist
|
||||
}
|
||||
|
@ -2064,7 +2064,7 @@ void MaterialStorage::global_shader_uniform_set_override(const StringName &p_nam
|
|||
}
|
||||
}
|
||||
|
||||
Variant MaterialStorage::global_shader_uniform_get(const StringName &p_name) const {
|
||||
Variant MaterialStorage::global_shader_parameter_get(const StringName &p_name) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_V_MSG(Variant(), "This function should never be used outside the editor, it can severely damage performance.");
|
||||
}
|
||||
|
@ -2076,7 +2076,7 @@ Variant MaterialStorage::global_shader_uniform_get(const StringName &p_name) con
|
|||
return global_shader_uniforms.variables[p_name].value;
|
||||
}
|
||||
|
||||
RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type_internal(const StringName &p_name) const {
|
||||
RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type_internal(const StringName &p_name) const {
|
||||
if (!global_shader_uniforms.variables.has(p_name)) {
|
||||
return RS::GLOBAL_VAR_TYPE_MAX;
|
||||
}
|
||||
|
@ -2084,15 +2084,15 @@ RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type_inte
|
|||
return global_shader_uniforms.variables[p_name].type;
|
||||
}
|
||||
|
||||
RS::GlobalShaderUniformType MaterialStorage::global_shader_uniform_get_type(const StringName &p_name) const {
|
||||
RS::GlobalShaderParameterType MaterialStorage::global_shader_parameter_get_type(const StringName &p_name) const {
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_V_MSG(RS::GLOBAL_VAR_TYPE_MAX, "This function should never be used outside the editor, it can severely damage performance.");
|
||||
}
|
||||
|
||||
return global_shader_uniform_get_type_internal(p_name);
|
||||
return global_shader_parameter_get_type_internal(p_name);
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures) {
|
||||
void MaterialStorage::global_shader_parameters_load_settings(bool p_load_textures) {
|
||||
List<PropertyInfo> settings;
|
||||
ProjectSettings::get_singleton()->get_property_list(&settings);
|
||||
|
||||
|
@ -2137,11 +2137,11 @@ void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures)
|
|||
"samplerCube",
|
||||
};
|
||||
|
||||
RS::GlobalShaderUniformType gvtype = RS::GLOBAL_VAR_TYPE_MAX;
|
||||
RS::GlobalShaderParameterType gvtype = RS::GLOBAL_VAR_TYPE_MAX;
|
||||
|
||||
for (int i = 0; i < RS::GLOBAL_VAR_TYPE_MAX; i++) {
|
||||
if (global_var_type_names[i] == type) {
|
||||
gvtype = RS::GlobalShaderUniformType(i);
|
||||
gvtype = RS::GlobalShaderParameterType(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2165,15 +2165,15 @@ void MaterialStorage::global_shader_uniforms_load_settings(bool p_load_textures)
|
|||
|
||||
if (global_shader_uniforms.variables.has(name)) {
|
||||
//has it, update it
|
||||
global_shader_uniform_set(name, value);
|
||||
global_shader_parameter_set(name, value);
|
||||
} else {
|
||||
global_shader_uniform_add(name, gvtype, value);
|
||||
global_shader_parameter_add(name, gvtype, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_clear() {
|
||||
void MaterialStorage::global_shader_parameters_clear() {
|
||||
global_shader_uniforms.variables.clear(); //not right but for now enough
|
||||
}
|
||||
|
||||
|
@ -2181,7 +2181,7 @@ RID MaterialStorage::global_shader_uniforms_get_storage_buffer() const {
|
|||
return global_shader_uniforms.buffer;
|
||||
}
|
||||
|
||||
int32_t MaterialStorage::global_shader_uniforms_instance_allocate(RID p_instance) {
|
||||
int32_t MaterialStorage::global_shader_parameters_instance_allocate(RID p_instance) {
|
||||
ERR_FAIL_COND_V(global_shader_uniforms.instance_buffer_pos.has(p_instance), -1);
|
||||
int32_t pos = _global_shader_uniform_allocate(ShaderLanguage::MAX_INSTANCE_UNIFORM_INDICES);
|
||||
global_shader_uniforms.instance_buffer_pos[p_instance] = pos; //save anyway
|
||||
|
@ -2190,7 +2190,7 @@ int32_t MaterialStorage::global_shader_uniforms_instance_allocate(RID p_instance
|
|||
return pos;
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_instance_free(RID p_instance) {
|
||||
void MaterialStorage::global_shader_parameters_instance_free(RID p_instance) {
|
||||
ERR_FAIL_COND(!global_shader_uniforms.instance_buffer_pos.has(p_instance));
|
||||
int32_t pos = global_shader_uniforms.instance_buffer_pos[p_instance];
|
||||
if (pos >= 0) {
|
||||
|
@ -2199,7 +2199,7 @@ void MaterialStorage::global_shader_uniforms_instance_free(RID p_instance) {
|
|||
global_shader_uniforms.instance_buffer_pos.erase(p_instance);
|
||||
}
|
||||
|
||||
void MaterialStorage::global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) {
|
||||
void MaterialStorage::global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) {
|
||||
if (!global_shader_uniforms.instance_buffer_pos.has(p_instance)) {
|
||||
return; //just not allocated, ignore
|
||||
}
|
||||
|
@ -2384,7 +2384,7 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) {
|
|||
if (shader->data) {
|
||||
for (const KeyValue<StringName, HashMap<int, RID>> &E : shader->default_texture_parameter) {
|
||||
for (const KeyValue<int, RID> &E2 : E.value) {
|
||||
shader->data->set_default_texture_param(E.key, E2.value, E2.key);
|
||||
shader->data->set_default_texture_parameter(E.key, E2.value, E2.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2418,7 +2418,7 @@ String MaterialStorage::shader_get_code(RID p_shader) const {
|
|||
return shader->code;
|
||||
}
|
||||
|
||||
void MaterialStorage::shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
|
||||
void MaterialStorage::get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
if (shader->data) {
|
||||
|
@ -2426,7 +2426,7 @@ void MaterialStorage::shader_get_shader_uniform_list(RID p_shader, List<Property
|
|||
}
|
||||
}
|
||||
|
||||
void MaterialStorage::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) {
|
||||
void MaterialStorage::shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND(!shader);
|
||||
|
||||
|
@ -2445,7 +2445,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin
|
|||
}
|
||||
}
|
||||
if (shader->data) {
|
||||
shader->data->set_default_texture_param(p_name, p_texture, p_index);
|
||||
shader->data->set_default_texture_parameter(p_name, p_texture, p_index);
|
||||
}
|
||||
for (Material *E : shader->owners) {
|
||||
Material *material = E;
|
||||
|
@ -2453,7 +2453,7 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin
|
|||
}
|
||||
}
|
||||
|
||||
RID MaterialStorage::shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const {
|
||||
RID MaterialStorage::shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, RID());
|
||||
if (shader->default_texture_parameter.has(p_name) && shader->default_texture_parameter[p_name].has(p_index)) {
|
||||
|
@ -2463,7 +2463,7 @@ RID MaterialStorage::shader_get_default_texture_param(RID p_shader, const String
|
|||
return RID();
|
||||
}
|
||||
|
||||
Variant MaterialStorage::shader_get_param_default(RID p_shader, const StringName &p_param) const {
|
||||
Variant MaterialStorage::shader_get_parameter_default(RID p_shader, const StringName &p_param) const {
|
||||
Shader *shader = shader_owner.get_or_null(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, Variant());
|
||||
if (shader->data) {
|
||||
|
@ -2616,7 +2616,7 @@ void MaterialStorage::material_set_param(RID p_material, const StringName &p_par
|
|||
}
|
||||
|
||||
if (material->shader && material->shader->data) { //shader is valid
|
||||
bool is_texture = material->shader->data->is_param_texture(p_param);
|
||||
bool is_texture = material->shader->data->is_parameter_texture(p_param);
|
||||
_material_queue_update(material, !is_texture, is_texture);
|
||||
} else {
|
||||
_material_queue_update(material, true, true);
|
||||
|
@ -2684,14 +2684,14 @@ bool MaterialStorage::material_casts_shadows(RID p_material) {
|
|||
return true; //by default everything casts shadows
|
||||
}
|
||||
|
||||
void MaterialStorage::material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) {
|
||||
void MaterialStorage::material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) {
|
||||
Material *material = material_owner.get_or_null(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
if (material->shader && material->shader->data) {
|
||||
material->shader->data->get_instance_param_list(r_parameters);
|
||||
|
||||
if (material->next_pass.is_valid()) {
|
||||
material_get_instance_shader_uniforms(material->next_pass, r_parameters);
|
||||
material_get_instance_shader_parameters(material->next_pass, r_parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,11 +56,11 @@ public:
|
|||
struct ShaderData {
|
||||
virtual void set_code(const String &p_Code) = 0;
|
||||
virtual void set_path_hint(const String &p_hint) = 0;
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) = 0;
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) = 0;
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const = 0;
|
||||
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const = 0;
|
||||
virtual bool is_param_texture(const StringName &p_param) const = 0;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const = 0;
|
||||
virtual bool is_animated() const = 0;
|
||||
virtual bool casts_shadows() const = 0;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const = 0;
|
||||
|
@ -119,7 +119,7 @@ private:
|
|||
struct Variable {
|
||||
HashSet<RID> texture_materials; // materials using this
|
||||
|
||||
RS::GlobalShaderUniformType type;
|
||||
RS::GlobalShaderParameterType type;
|
||||
Variant value;
|
||||
Variant override;
|
||||
int32_t buffer_index; //for vectors
|
||||
|
@ -171,7 +171,7 @@ private:
|
|||
} global_shader_uniforms;
|
||||
|
||||
int32_t _global_shader_uniform_allocate(uint32_t p_elements);
|
||||
void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderUniformType p_type, const Variant &p_value);
|
||||
void _global_shader_uniform_store_in_buffer(int32_t p_index, RS::GlobalShaderParameterType p_type, const Variant &p_value);
|
||||
void _global_shader_uniform_mark_buffer_dirty(int32_t p_index, int32_t p_elements);
|
||||
|
||||
/* SHADER API */
|
||||
|
@ -332,22 +332,22 @@ public:
|
|||
|
||||
void _update_global_shader_uniforms();
|
||||
|
||||
virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) override;
|
||||
virtual void global_shader_uniform_remove(const StringName &p_name) override;
|
||||
virtual Vector<StringName> global_shader_uniform_get_list() const override;
|
||||
virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) override;
|
||||
virtual void global_shader_parameter_remove(const StringName &p_name) override;
|
||||
virtual Vector<StringName> global_shader_parameter_get_list() const override;
|
||||
|
||||
virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual Variant global_shader_uniform_get(const StringName &p_name) const override;
|
||||
virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const override;
|
||||
RS::GlobalShaderUniformType global_shader_uniform_get_type_internal(const StringName &p_name) const;
|
||||
virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) override;
|
||||
virtual Variant global_shader_parameter_get(const StringName &p_name) const override;
|
||||
virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const override;
|
||||
RS::GlobalShaderParameterType global_shader_parameter_get_type_internal(const StringName &p_name) const;
|
||||
|
||||
virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) override;
|
||||
virtual void global_shader_uniforms_clear() override;
|
||||
virtual void global_shader_parameters_load_settings(bool p_load_textures = true) override;
|
||||
virtual void global_shader_parameters_clear() override;
|
||||
|
||||
virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) override;
|
||||
virtual void global_shader_uniforms_instance_free(RID p_instance) override;
|
||||
virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) override;
|
||||
virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) override;
|
||||
virtual void global_shader_parameters_instance_free(RID p_instance) override;
|
||||
virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) override;
|
||||
|
||||
RID global_shader_uniforms_get_storage_buffer() const;
|
||||
|
||||
|
@ -362,11 +362,11 @@ public:
|
|||
virtual void shader_set_code(RID p_shader, const String &p_code) override;
|
||||
virtual void shader_set_path_hint(RID p_shader, const String &p_path) override;
|
||||
virtual String shader_get_code(RID p_shader) const override;
|
||||
virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const override;
|
||||
virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const override;
|
||||
|
||||
virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override;
|
||||
virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const override;
|
||||
virtual Variant shader_get_param_default(RID p_shader, const StringName &p_param) const override;
|
||||
virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) override;
|
||||
virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const override;
|
||||
virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_param) const override;
|
||||
void shader_set_data_request_function(ShaderType p_shader_type, ShaderDataRequestFunction p_function);
|
||||
|
||||
virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const override;
|
||||
|
@ -394,7 +394,7 @@ public:
|
|||
virtual bool material_is_animated(RID p_material) override;
|
||||
virtual bool material_casts_shadows(RID p_material) override;
|
||||
|
||||
virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) override;
|
||||
virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) override;
|
||||
|
||||
virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) override;
|
||||
|
||||
|
|
|
@ -1586,7 +1586,7 @@ void ParticlesStorage::ParticlesShaderData::set_code(const String &p_code) {
|
|||
valid = true;
|
||||
}
|
||||
|
||||
void ParticlesStorage::ParticlesShaderData::set_default_texture_param(const StringName &p_name, RID p_texture, int p_index) {
|
||||
void ParticlesStorage::ParticlesShaderData::set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index) {
|
||||
if (!p_texture.is_valid()) {
|
||||
if (default_texture_params.has(p_name) && default_texture_params[p_name].has(p_index)) {
|
||||
default_texture_params[p_name].erase(p_index);
|
||||
|
@ -1655,7 +1655,7 @@ void ParticlesStorage::ParticlesShaderData::get_instance_param_list(List<Rendere
|
|||
}
|
||||
}
|
||||
|
||||
bool ParticlesStorage::ParticlesShaderData::is_param_texture(const StringName &p_param) const {
|
||||
bool ParticlesStorage::ParticlesShaderData::is_parameter_texture(const StringName &p_param) const {
|
||||
if (!uniforms.has(p_param)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -336,10 +336,10 @@ private:
|
|||
|
||||
virtual void set_code(const String &p_Code);
|
||||
virtual void set_path_hint(const String &p_hint);
|
||||
virtual void set_default_texture_param(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void set_default_texture_parameter(const StringName &p_name, RID p_texture, int p_index);
|
||||
virtual void get_shader_uniform_list(List<PropertyInfo> *p_param_list) const;
|
||||
virtual void get_instance_param_list(List<RendererMaterialStorage::InstanceShaderParam> *p_param_list) const;
|
||||
virtual bool is_param_texture(const StringName &p_param) const;
|
||||
virtual bool is_parameter_texture(const StringName &p_param) const;
|
||||
virtual bool is_animated() const;
|
||||
virtual bool casts_shadows() const;
|
||||
virtual Variant get_default_parameter(const StringName &p_parameter) const;
|
||||
|
|
|
@ -100,10 +100,10 @@ public:
|
|||
virtual void instance_geometry_set_visibility_range(RID p_instance, float p_min, float p_max, float p_min_margin, float p_max_margin, RS::VisibilityRangeFadeMode p_fade_mode) = 0;
|
||||
virtual void instance_geometry_set_lightmap(RID p_instance, RID p_lightmap, const Rect2 &p_lightmap_uv_scale, int p_slice_index) = 0;
|
||||
virtual void instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) = 0;
|
||||
virtual void instance_geometry_set_shader_uniform(RID p_instance, const StringName &p_parameter, const Variant &p_value) = 0;
|
||||
virtual void instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0;
|
||||
virtual Variant instance_geometry_get_shader_uniform(RID p_instance, const StringName &p_parameter) const = 0;
|
||||
virtual Variant instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &p_parameter) const = 0;
|
||||
virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) = 0;
|
||||
virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0;
|
||||
virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const = 0;
|
||||
virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const = 0;
|
||||
|
||||
virtual void directional_shadow_atlas_set_size(int p_size, bool p_16_bits = true) = 0;
|
||||
|
||||
|
|
|
@ -1436,7 +1436,7 @@ void RendererSceneCull::instance_geometry_set_lod_bias(RID p_instance, float p_l
|
|||
}
|
||||
}
|
||||
|
||||
void RendererSceneCull::instance_geometry_set_shader_uniform(RID p_instance, const StringName &p_parameter, const Variant &p_value) {
|
||||
void RendererSceneCull::instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value) {
|
||||
Instance *instance = instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
|
||||
|
@ -1454,12 +1454,12 @@ void RendererSceneCull::instance_geometry_set_shader_uniform(RID p_instance, con
|
|||
E->value.value = p_value;
|
||||
if (E->value.index >= 0 && instance->instance_allocated_shader_uniforms) {
|
||||
//update directly
|
||||
RSG::material_storage->global_shader_uniforms_instance_update(p_instance, E->value.index, p_value);
|
||||
RSG::material_storage->global_shader_parameters_instance_update(p_instance, E->value.index, p_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Variant RendererSceneCull::instance_geometry_get_shader_uniform(RID p_instance, const StringName &p_parameter) const {
|
||||
Variant RendererSceneCull::instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const {
|
||||
const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!instance, Variant());
|
||||
|
||||
|
@ -1469,7 +1469,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_uniform(RID p_instance,
|
|||
return Variant();
|
||||
}
|
||||
|
||||
Variant RendererSceneCull::instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &p_parameter) const {
|
||||
Variant RendererSceneCull::instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const {
|
||||
const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND_V(!instance, Variant());
|
||||
|
||||
|
@ -1479,7 +1479,7 @@ Variant RendererSceneCull::instance_geometry_get_shader_uniform_default_value(RI
|
|||
return Variant();
|
||||
}
|
||||
|
||||
void RendererSceneCull::instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const {
|
||||
void RendererSceneCull::instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const {
|
||||
const Instance *instance = const_cast<RendererSceneCull *>(this)->instance_owner.get_or_null(p_instance);
|
||||
ERR_FAIL_COND(!instance);
|
||||
|
||||
|
@ -3673,7 +3673,7 @@ void RendererSceneCull::render_particle_colliders() {
|
|||
|
||||
void RendererSceneCull::_update_instance_shader_uniforms_from_material(HashMap<StringName, Instance::InstanceShaderParameter> &isparams, const HashMap<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material) {
|
||||
List<RendererMaterialStorage::InstanceShaderParam> plist;
|
||||
RSG::material_storage->material_get_instance_shader_uniforms(p_material, &plist);
|
||||
RSG::material_storage->material_get_instance_shader_parameters(p_material, &plist);
|
||||
for (const RendererMaterialStorage::InstanceShaderParam &E : plist) {
|
||||
StringName name = E.info.name;
|
||||
if (isparams.has(name)) {
|
||||
|
@ -3879,17 +3879,17 @@ void RendererSceneCull::_update_dirty_instance(Instance *p_instance) {
|
|||
if (p_instance->instance_allocated_shader_uniforms != (p_instance->instance_shader_uniforms.size() > 0)) {
|
||||
p_instance->instance_allocated_shader_uniforms = (p_instance->instance_shader_uniforms.size() > 0);
|
||||
if (p_instance->instance_allocated_shader_uniforms) {
|
||||
p_instance->instance_allocated_shader_uniforms_offset = RSG::material_storage->global_shader_uniforms_instance_allocate(p_instance->self);
|
||||
p_instance->instance_allocated_shader_uniforms_offset = RSG::material_storage->global_shader_parameters_instance_allocate(p_instance->self);
|
||||
ERR_FAIL_NULL(geom->geometry_instance);
|
||||
geom->geometry_instance->set_instance_shader_uniforms_offset(p_instance->instance_allocated_shader_uniforms_offset);
|
||||
|
||||
for (const KeyValue<StringName, Instance::InstanceShaderParameter> &E : p_instance->instance_shader_uniforms) {
|
||||
if (E.value.value.get_type() != Variant::NIL) {
|
||||
RSG::material_storage->global_shader_uniforms_instance_update(p_instance->self, E.value.index, E.value.value);
|
||||
RSG::material_storage->global_shader_parameters_instance_update(p_instance->self, E.value.index, E.value.value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RSG::material_storage->global_shader_uniforms_instance_free(p_instance->self);
|
||||
RSG::material_storage->global_shader_parameters_instance_free(p_instance->self);
|
||||
p_instance->instance_allocated_shader_uniforms_offset = -1;
|
||||
ERR_FAIL_NULL(geom->geometry_instance);
|
||||
geom->geometry_instance->set_instance_shader_uniforms_offset(-1);
|
||||
|
@ -3987,7 +3987,7 @@ bool RendererSceneCull::free(RID p_rid) {
|
|||
|
||||
if (instance->instance_allocated_shader_uniforms) {
|
||||
//free the used shader parameters
|
||||
RSG::material_storage->global_shader_uniforms_instance_free(instance->self);
|
||||
RSG::material_storage->global_shader_parameters_instance_free(instance->self);
|
||||
}
|
||||
update_dirty_instances(); //in case something changed this
|
||||
|
||||
|
|
|
@ -969,10 +969,10 @@ public:
|
|||
|
||||
void _update_instance_shader_uniforms_from_material(HashMap<StringName, Instance::InstanceShaderParameter> &isparams, const HashMap<StringName, Instance::InstanceShaderParameter> &existing_isparams, RID p_material);
|
||||
|
||||
virtual void instance_geometry_set_shader_uniform(RID p_instance, const StringName &p_parameter, const Variant &p_value);
|
||||
virtual void instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const;
|
||||
virtual Variant instance_geometry_get_shader_uniform(RID p_instance, const StringName &p_parameter) const;
|
||||
virtual Variant instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &p_parameter) const;
|
||||
virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &p_parameter, const Variant &p_value);
|
||||
virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const;
|
||||
virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &p_parameter) const;
|
||||
virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &p_parameter) const;
|
||||
|
||||
_FORCE_INLINE_ void _update_instance(Instance *p_instance);
|
||||
_FORCE_INLINE_ void _update_instance_aabb(Instance *p_instance);
|
||||
|
|
|
@ -227,11 +227,11 @@ public:
|
|||
FUNC2(shader_set_path_hint, RID, const String &)
|
||||
FUNC1RC(String, shader_get_code, RID)
|
||||
|
||||
FUNC2SC(shader_get_shader_uniform_list, RID, List<PropertyInfo> *)
|
||||
FUNC2SC(get_shader_parameter_list, RID, List<PropertyInfo> *)
|
||||
|
||||
FUNC4(shader_set_default_texture_param, RID, const StringName &, RID, int)
|
||||
FUNC3RC(RID, shader_get_default_texture_param, RID, const StringName &, int)
|
||||
FUNC2RC(Variant, shader_get_param_default, RID, const StringName &)
|
||||
FUNC4(shader_set_default_texture_parameter, RID, const StringName &, RID, int)
|
||||
FUNC3RC(RID, shader_get_default_texture_parameter, RID, const StringName &, int)
|
||||
FUNC2RC(Variant, shader_get_parameter_default, RID, const StringName &)
|
||||
|
||||
FUNC1RC(ShaderNativeSourceCode, shader_get_native_source_code, RID)
|
||||
|
||||
|
@ -774,10 +774,10 @@ public:
|
|||
FUNC4(instance_geometry_set_lightmap, RID, RID, const Rect2 &, int)
|
||||
FUNC2(instance_geometry_set_lod_bias, RID, float)
|
||||
FUNC2(instance_geometry_set_transparency, RID, float)
|
||||
FUNC3(instance_geometry_set_shader_uniform, RID, const StringName &, const Variant &)
|
||||
FUNC2RC(Variant, instance_geometry_get_shader_uniform, RID, const StringName &)
|
||||
FUNC2RC(Variant, instance_geometry_get_shader_uniform_default_value, RID, const StringName &)
|
||||
FUNC2C(instance_geometry_get_shader_uniform_list, RID, List<PropertyInfo> *)
|
||||
FUNC3(instance_geometry_set_shader_parameter, RID, const StringName &, const Variant &)
|
||||
FUNC2RC(Variant, instance_geometry_get_shader_parameter, RID, const StringName &)
|
||||
FUNC2RC(Variant, instance_geometry_get_shader_parameter_default_value, RID, const StringName &)
|
||||
FUNC2C(instance_geometry_get_shader_parameter_list, RID, List<PropertyInfo> *)
|
||||
|
||||
FUNC3R(TypedArray<Image>, bake_render_uv2, RID, const Vector<RID> &, const Size2i &)
|
||||
|
||||
|
@ -910,16 +910,16 @@ public:
|
|||
#define ServerName RendererMaterialStorage
|
||||
#define server_name RSG::material_storage
|
||||
|
||||
FUNC3(global_shader_uniform_add, const StringName &, GlobalShaderUniformType, const Variant &)
|
||||
FUNC1(global_shader_uniform_remove, const StringName &)
|
||||
FUNC0RC(Vector<StringName>, global_shader_uniform_get_list)
|
||||
FUNC2(global_shader_uniform_set, const StringName &, const Variant &)
|
||||
FUNC2(global_shader_uniform_set_override, const StringName &, const Variant &)
|
||||
FUNC1RC(GlobalShaderUniformType, global_shader_uniform_get_type, const StringName &)
|
||||
FUNC1RC(Variant, global_shader_uniform_get, const StringName &)
|
||||
FUNC3(global_shader_parameter_add, const StringName &, GlobalShaderParameterType, const Variant &)
|
||||
FUNC1(global_shader_parameter_remove, const StringName &)
|
||||
FUNC0RC(Vector<StringName>, global_shader_parameter_get_list)
|
||||
FUNC2(global_shader_parameter_set, const StringName &, const Variant &)
|
||||
FUNC2(global_shader_parameter_set_override, const StringName &, const Variant &)
|
||||
FUNC1RC(GlobalShaderParameterType, global_shader_parameter_get_type, const StringName &)
|
||||
FUNC1RC(Variant, global_shader_parameter_get, const StringName &)
|
||||
|
||||
FUNC1(global_shader_uniforms_load_settings, bool)
|
||||
FUNC0(global_shader_uniforms_clear)
|
||||
FUNC1(global_shader_parameters_load_settings, bool)
|
||||
FUNC0(global_shader_parameters_clear)
|
||||
|
||||
#undef server_name
|
||||
#undef ServerName
|
||||
|
|
|
@ -1349,7 +1349,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
|
|||
}
|
||||
|
||||
ShaderLanguage::DataType ShaderCompiler::_get_variable_type(const StringName &p_type) {
|
||||
RS::GlobalShaderUniformType gvt = RS::get_singleton()->global_shader_uniform_get_type(p_type);
|
||||
RS::GlobalShaderParameterType gvt = RS::get_singleton()->global_shader_parameter_get_type(p_type);
|
||||
return (ShaderLanguage::DataType)RS::global_shader_uniform_type_get_shader_datatype(gvt);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,21 +39,21 @@ public:
|
|||
virtual ~RendererMaterialStorage(){};
|
||||
|
||||
/* GLOBAL SHADER UNIFORM API */
|
||||
virtual void global_shader_uniform_add(const StringName &p_name, RS::GlobalShaderUniformType p_type, const Variant &p_value) = 0;
|
||||
virtual void global_shader_uniform_remove(const StringName &p_name) = 0;
|
||||
virtual Vector<StringName> global_shader_uniform_get_list() const = 0;
|
||||
virtual void global_shader_parameter_add(const StringName &p_name, RS::GlobalShaderParameterType p_type, const Variant &p_value) = 0;
|
||||
virtual void global_shader_parameter_remove(const StringName &p_name) = 0;
|
||||
virtual Vector<StringName> global_shader_parameter_get_list() const = 0;
|
||||
|
||||
virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual Variant global_shader_uniform_get(const StringName &p_name) const = 0;
|
||||
virtual RS::GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const = 0;
|
||||
virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual Variant global_shader_parameter_get(const StringName &p_name) const = 0;
|
||||
virtual RS::GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const = 0;
|
||||
|
||||
virtual void global_shader_uniforms_load_settings(bool p_load_textures = true) = 0;
|
||||
virtual void global_shader_uniforms_clear() = 0;
|
||||
virtual void global_shader_parameters_load_settings(bool p_load_textures = true) = 0;
|
||||
virtual void global_shader_parameters_clear() = 0;
|
||||
|
||||
virtual int32_t global_shader_uniforms_instance_allocate(RID p_instance) = 0;
|
||||
virtual void global_shader_uniforms_instance_free(RID p_instance) = 0;
|
||||
virtual void global_shader_uniforms_instance_update(RID p_instance, int p_index, const Variant &p_value) = 0;
|
||||
virtual int32_t global_shader_parameters_instance_allocate(RID p_instance) = 0;
|
||||
virtual void global_shader_parameters_instance_free(RID p_instance) = 0;
|
||||
virtual void global_shader_parameters_instance_update(RID p_instance, int p_index, const Variant &p_value) = 0;
|
||||
|
||||
/* SHADER API */
|
||||
virtual RID shader_allocate() = 0;
|
||||
|
@ -63,11 +63,11 @@ public:
|
|||
virtual void shader_set_code(RID p_shader, const String &p_code) = 0;
|
||||
virtual void shader_set_path_hint(RID p_shader, const String &p_path) = 0;
|
||||
virtual String shader_get_code(RID p_shader) const = 0;
|
||||
virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
|
||||
virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
|
||||
|
||||
virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index) = 0;
|
||||
virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index) const = 0;
|
||||
virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const = 0;
|
||||
virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index) = 0;
|
||||
virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index) const = 0;
|
||||
virtual Variant shader_get_parameter_default(RID p_material, const StringName &p_param) const = 0;
|
||||
|
||||
virtual RS::ShaderNativeSourceCode shader_get_native_source_code(RID p_shader) const = 0;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public:
|
|||
Variant default_value;
|
||||
};
|
||||
|
||||
virtual void material_get_instance_shader_uniforms(RID p_material, List<InstanceShaderParam> *r_parameters) = 0;
|
||||
virtual void material_get_instance_shader_parameters(RID p_material, List<InstanceShaderParam> *r_parameters) = 0;
|
||||
|
||||
virtual void material_update_dependency(RID p_material, DependencyTracker *p_instance) = 0;
|
||||
};
|
||||
|
|
|
@ -1400,7 +1400,7 @@ Array RenderingServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_su
|
|||
}
|
||||
#endif
|
||||
|
||||
int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderUniformType p_type) {
|
||||
int RenderingServer::global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type) {
|
||||
switch (p_type) {
|
||||
case RS::GLOBAL_VAR_TYPE_BOOL:
|
||||
return ShaderLanguage::TYPE_BOOL;
|
||||
|
@ -1501,9 +1501,9 @@ TypedArray<Image> RenderingServer::_texture_3d_get(RID p_texture) const {
|
|||
return ret;
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> RenderingServer::_shader_get_shader_uniform_list(RID p_shader) const {
|
||||
TypedArray<Dictionary> RenderingServer::_shader_get_shader_parameter_list(RID p_shader) const {
|
||||
List<PropertyInfo> l;
|
||||
shader_get_shader_uniform_list(p_shader, &l);
|
||||
get_shader_parameter_list(p_shader, &l);
|
||||
return convert_property_list(&l);
|
||||
}
|
||||
|
||||
|
@ -1626,9 +1626,9 @@ Dictionary RenderingServer::_mesh_get_surface(RID p_mesh, int p_idx) {
|
|||
return d;
|
||||
}
|
||||
|
||||
TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_uniform_list(RID p_instance) const {
|
||||
TypedArray<Dictionary> RenderingServer::_instance_geometry_get_shader_parameter_list(RID p_instance) const {
|
||||
List<PropertyInfo> params;
|
||||
instance_geometry_get_shader_uniform_list(p_instance, ¶ms);
|
||||
instance_geometry_get_shader_parameter_list(p_instance, ¶ms);
|
||||
return convert_property_list(¶ms);
|
||||
}
|
||||
|
||||
|
@ -1702,11 +1702,11 @@ void RenderingServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("shader_set_code", "shader", "code"), &RenderingServer::shader_set_code);
|
||||
ClassDB::bind_method(D_METHOD("shader_set_path_hint", "shader", "path"), &RenderingServer::shader_set_path_hint);
|
||||
ClassDB::bind_method(D_METHOD("shader_get_code", "shader"), &RenderingServer::shader_get_code);
|
||||
ClassDB::bind_method(D_METHOD("shader_get_shader_uniform_list", "shader"), &RenderingServer::_shader_get_shader_uniform_list);
|
||||
ClassDB::bind_method(D_METHOD("shader_get_param_default", "shader", "param"), &RenderingServer::shader_get_param_default);
|
||||
ClassDB::bind_method(D_METHOD("get_shader_parameter_list", "shader"), &RenderingServer::_shader_get_shader_parameter_list);
|
||||
ClassDB::bind_method(D_METHOD("shader_get_parameter_default", "shader", "name"), &RenderingServer::shader_get_parameter_default);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "param", "texture", "index"), &RenderingServer::shader_set_default_texture_param, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "param", "index"), &RenderingServer::shader_get_default_texture_param, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("shader_set_default_texture_parameter", "shader", "name", "texture", "index"), &RenderingServer::shader_set_default_texture_parameter, DEFVAL(0));
|
||||
ClassDB::bind_method(D_METHOD("shader_get_default_texture_parameter", "shader", "name", "index"), &RenderingServer::shader_get_default_texture_parameter, DEFVAL(0));
|
||||
|
||||
BIND_ENUM_CONSTANT(SHADER_SPATIAL);
|
||||
BIND_ENUM_CONSTANT(SHADER_CANVAS_ITEM);
|
||||
|
@ -2487,10 +2487,10 @@ void RenderingServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("instance_geometry_set_lightmap", "instance", "lightmap", "lightmap_uv_scale", "lightmap_slice"), &RenderingServer::instance_geometry_set_lightmap);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_set_lod_bias", "instance", "lod_bias"), &RenderingServer::instance_geometry_set_lod_bias);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_uniform", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_uniform);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_uniform", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_uniform);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_uniform_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_uniform_default_value);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_uniform_list", "instance"), &RenderingServer::_instance_geometry_get_shader_uniform_list);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_set_shader_parameter", "instance", "parameter", "value"), &RenderingServer::instance_geometry_set_shader_parameter);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_default_value", "instance", "parameter"), &RenderingServer::instance_geometry_get_shader_parameter_default_value);
|
||||
ClassDB::bind_method(D_METHOD("instance_geometry_get_shader_parameter_list", "instance"), &RenderingServer::_instance_geometry_get_shader_parameter_list);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("instances_cull_aabb", "aabb", "scenario"), &RenderingServer::_instances_cull_aabb_bind, DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("instances_cull_ray", "from", "to", "scenario"), &RenderingServer::_instances_cull_ray_bind, DEFVAL(RID()));
|
||||
|
@ -2687,13 +2687,13 @@ void RenderingServer::_bind_methods() {
|
|||
|
||||
/* GLOBAL SHADER UNIFORMS */
|
||||
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_add", "name", "type", "default_value"), &RenderingServer::global_shader_uniform_add);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_remove", "name"), &RenderingServer::global_shader_uniform_remove);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_get_list"), &RenderingServer::global_shader_uniform_get_list);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_set", "name", "value"), &RenderingServer::global_shader_uniform_set);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_set_override", "name", "value"), &RenderingServer::global_shader_uniform_set_override);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_get", "name"), &RenderingServer::global_shader_uniform_get);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_uniform_get_type", "name"), &RenderingServer::global_shader_uniform_get_type);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_add", "name", "type", "default_value"), &RenderingServer::global_shader_parameter_add);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_remove", "name"), &RenderingServer::global_shader_parameter_remove);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_get_list"), &RenderingServer::global_shader_parameter_get_list);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_set", "name", "value"), &RenderingServer::global_shader_parameter_set);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_set_override", "name", "value"), &RenderingServer::global_shader_parameter_set_override);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_get", "name"), &RenderingServer::global_shader_parameter_get);
|
||||
ClassDB::bind_method(D_METHOD("global_shader_parameter_get_type", "name"), &RenderingServer::global_shader_parameter_get_type);
|
||||
|
||||
BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BOOL);
|
||||
BIND_ENUM_CONSTANT(GLOBAL_VAR_TYPE_BVEC2);
|
||||
|
|
|
@ -173,11 +173,11 @@ public:
|
|||
virtual void shader_set_code(RID p_shader, const String &p_code) = 0;
|
||||
virtual void shader_set_path_hint(RID p_shader, const String &p_path) = 0;
|
||||
virtual String shader_get_code(RID p_shader) const = 0;
|
||||
virtual void shader_get_shader_uniform_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
|
||||
virtual Variant shader_get_param_default(RID p_shader, const StringName &p_param) const = 0;
|
||||
virtual void get_shader_parameter_list(RID p_shader, List<PropertyInfo> *p_param_list) const = 0;
|
||||
virtual Variant shader_get_parameter_default(RID p_shader, const StringName &p_param) const = 0;
|
||||
|
||||
virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture, int p_index = 0) = 0;
|
||||
virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name, int p_index = 0) const = 0;
|
||||
virtual void shader_set_default_texture_parameter(RID p_shader, const StringName &p_name, RID p_texture, int p_index = 0) = 0;
|
||||
virtual RID shader_get_default_texture_parameter(RID p_shader, const StringName &p_name, int p_index = 0) const = 0;
|
||||
|
||||
struct ShaderNativeSourceCode {
|
||||
struct Version {
|
||||
|
@ -1251,10 +1251,10 @@ public:
|
|||
virtual void instance_geometry_set_lod_bias(RID p_instance, float p_lod_bias) = 0;
|
||||
virtual void instance_geometry_set_transparency(RID p_instance, float p_transparency) = 0;
|
||||
|
||||
virtual void instance_geometry_set_shader_uniform(RID p_instance, const StringName &, const Variant &p_value) = 0;
|
||||
virtual Variant instance_geometry_get_shader_uniform(RID p_instance, const StringName &) const = 0;
|
||||
virtual Variant instance_geometry_get_shader_uniform_default_value(RID p_instance, const StringName &) const = 0;
|
||||
virtual void instance_geometry_get_shader_uniform_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0;
|
||||
virtual void instance_geometry_set_shader_parameter(RID p_instance, const StringName &, const Variant &p_value) = 0;
|
||||
virtual Variant instance_geometry_get_shader_parameter(RID p_instance, const StringName &) const = 0;
|
||||
virtual Variant instance_geometry_get_shader_parameter_default_value(RID p_instance, const StringName &) const = 0;
|
||||
virtual void instance_geometry_get_shader_parameter_list(RID p_instance, List<PropertyInfo> *p_parameters) const = 0;
|
||||
|
||||
/* Bake 3D objects */
|
||||
|
||||
|
@ -1437,7 +1437,7 @@ public:
|
|||
|
||||
/* GLOBAL SHADER UNIFORMS */
|
||||
|
||||
enum GlobalShaderUniformType {
|
||||
enum GlobalShaderParameterType {
|
||||
GLOBAL_VAR_TYPE_BOOL,
|
||||
GLOBAL_VAR_TYPE_BVEC2,
|
||||
GLOBAL_VAR_TYPE_BVEC3,
|
||||
|
@ -1469,20 +1469,20 @@ public:
|
|||
GLOBAL_VAR_TYPE_MAX
|
||||
};
|
||||
|
||||
virtual void global_shader_uniform_add(const StringName &p_name, GlobalShaderUniformType p_type, const Variant &p_value) = 0;
|
||||
virtual void global_shader_uniform_remove(const StringName &p_name) = 0;
|
||||
virtual Vector<StringName> global_shader_uniform_get_list() const = 0;
|
||||
virtual void global_shader_parameter_add(const StringName &p_name, GlobalShaderParameterType p_type, const Variant &p_value) = 0;
|
||||
virtual void global_shader_parameter_remove(const StringName &p_name) = 0;
|
||||
virtual Vector<StringName> global_shader_parameter_get_list() const = 0;
|
||||
|
||||
virtual void global_shader_uniform_set(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual void global_shader_uniform_set_override(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual void global_shader_parameter_set(const StringName &p_name, const Variant &p_value) = 0;
|
||||
virtual void global_shader_parameter_set_override(const StringName &p_name, const Variant &p_value) = 0;
|
||||
|
||||
virtual Variant global_shader_uniform_get(const StringName &p_name) const = 0;
|
||||
virtual GlobalShaderUniformType global_shader_uniform_get_type(const StringName &p_name) const = 0;
|
||||
virtual Variant global_shader_parameter_get(const StringName &p_name) const = 0;
|
||||
virtual GlobalShaderParameterType global_shader_parameter_get_type(const StringName &p_name) const = 0;
|
||||
|
||||
virtual void global_shader_uniforms_load_settings(bool p_load_textures) = 0;
|
||||
virtual void global_shader_uniforms_clear() = 0;
|
||||
virtual void global_shader_parameters_load_settings(bool p_load_textures) = 0;
|
||||
virtual void global_shader_parameters_clear() = 0;
|
||||
|
||||
static int global_shader_uniform_type_get_shader_datatype(GlobalShaderUniformType p_type);
|
||||
static int global_shader_uniform_type_get_shader_datatype(GlobalShaderParameterType p_type);
|
||||
|
||||
/* FREE */
|
||||
|
||||
|
@ -1579,11 +1579,11 @@ private:
|
|||
RID _texture_3d_create(Image::Format p_format, int p_width, int p_height, int p_depth, bool p_mipmaps, const TypedArray<Image> &p_data);
|
||||
void _texture_3d_update(RID p_texture, const TypedArray<Image> &p_data);
|
||||
TypedArray<Image> _texture_3d_get(RID p_texture) const;
|
||||
TypedArray<Dictionary> _shader_get_shader_uniform_list(RID p_shader) const;
|
||||
TypedArray<Dictionary> _shader_get_shader_parameter_list(RID p_shader) const;
|
||||
RID _mesh_create_from_surfaces(const TypedArray<Dictionary> &p_surfaces, int p_blend_shape_count);
|
||||
void _mesh_add_surface(RID p_mesh, const Dictionary &p_surface);
|
||||
Dictionary _mesh_get_surface(RID p_mesh, int p_idx);
|
||||
TypedArray<Dictionary> _instance_geometry_get_shader_uniform_list(RID p_instance) const;
|
||||
TypedArray<Dictionary> _instance_geometry_get_shader_parameter_list(RID p_instance) const;
|
||||
TypedArray<Image> _bake_render_uv2(RID p_base, const TypedArray<RID> &p_material_overrides, const Size2i &p_image_size);
|
||||
void _particles_set_trail_bind_poses(RID p_particles, const TypedArray<Transform3D> &p_bind_poses);
|
||||
};
|
||||
|
@ -1658,7 +1658,7 @@ VARIANT_ENUM_CAST(RenderingServer::CanvasLightMode);
|
|||
VARIANT_ENUM_CAST(RenderingServer::CanvasLightBlendMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::CanvasLightShadowFilter);
|
||||
VARIANT_ENUM_CAST(RenderingServer::CanvasOccluderPolygonCullMode);
|
||||
VARIANT_ENUM_CAST(RenderingServer::GlobalShaderUniformType);
|
||||
VARIANT_ENUM_CAST(RenderingServer::GlobalShaderParameterType);
|
||||
VARIANT_ENUM_CAST(RenderingServer::RenderingInfo);
|
||||
VARIANT_ENUM_CAST(RenderingServer::Features);
|
||||
VARIANT_ENUM_CAST(RenderingServer::CanvasTextureChannel);
|
||||
|
|
|
@ -282,7 +282,7 @@ struct GodotTestCaseListener : public doctest::IReporter {
|
|||
|
||||
if (RenderingServer::get_singleton()) {
|
||||
RenderingServer::get_singleton()->sync();
|
||||
RenderingServer::get_singleton()->global_shader_uniforms_clear();
|
||||
RenderingServer::get_singleton()->global_shader_parameters_clear();
|
||||
RenderingServer::get_singleton()->finish();
|
||||
memdelete(RenderingServer::get_singleton());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue