@@ -5213,12 +5213,22 @@ String VisualShaderNodeFloatParameter::get_output_port_name(int p_port) const {
52135213
52145214String VisualShaderNodeFloatParameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
52155215 String code = " " ;
5216+ bool add_comma = true ;
52165217 if (hint == HINT_RANGE) {
52175218 code += _get_qual_str () + " uniform float " + get_parameter_name () + " : hint_range(" + rtos (hint_range_min) + " , " + rtos (hint_range_max) + " )" ;
52185219 } else if (hint == HINT_RANGE_STEP) {
52195220 code += _get_qual_str () + " uniform float " + get_parameter_name () + " : hint_range(" + rtos (hint_range_min) + " , " + rtos (hint_range_max) + " , " + rtos (hint_range_step) + " )" ;
52205221 } else {
52215222 code += _get_qual_str () + " uniform float " + get_parameter_name ();
5223+ add_comma = false ;
5224+ }
5225+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
5226+ if (add_comma) {
5227+ code += " , " ;
5228+ } else {
5229+ code += " : " ;
5230+ }
5231+ code += vformat (" instance_index(%d)" , get_instance_index ());
52225232 }
52235233 if (default_value_enabled) {
52245234 code += " = " + rtos (default_value);
@@ -5404,6 +5414,7 @@ String VisualShaderNodeIntParameter::get_output_port_name(int p_port) const {
54045414
54055415String VisualShaderNodeIntParameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
54065416 String code = " " ;
5417+ bool add_comma = true ;
54075418 if (hint == HINT_RANGE) {
54085419 code += _get_qual_str () + " uniform int " + get_parameter_name () + " : hint_range(" + itos (hint_range_min) + " , " + itos (hint_range_max) + " )" ;
54095420 } else if (hint == HINT_RANGE_STEP) {
@@ -5424,6 +5435,15 @@ String VisualShaderNodeIntParameter::generate_global(Shader::Mode p_mode, Visual
54245435 code += " )" ;
54255436 } else {
54265437 code += _get_qual_str () + " uniform int " + get_parameter_name ();
5438+ add_comma = false ;
5439+ }
5440+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
5441+ if (add_comma) {
5442+ code += " , " ;
5443+ } else {
5444+ code += " : " ;
5445+ }
5446+ code += vformat (" instance_index(%d)" , get_instance_index ());
54275447 }
54285448 if (default_value_enabled) {
54295449 code += " = " + itos (default_value);
@@ -5629,6 +5649,9 @@ String VisualShaderNodeUIntParameter::get_output_port_name(int p_port) const {
56295649
56305650String VisualShaderNodeUIntParameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
56315651 String code = _get_qual_str () + " uniform uint " + get_parameter_name ();
5652+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
5653+ code += vformat (" : instance_index(%d)" , get_instance_index ());
5654+ }
56325655 if (default_value_enabled) {
56335656 code += " = " + itos (default_value);
56345657 }
@@ -5759,6 +5782,9 @@ bool VisualShaderNodeBooleanParameter::get_default_value() const {
57595782
57605783String VisualShaderNodeBooleanParameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
57615784 String code = _get_qual_str () + " uniform bool " + get_parameter_name ();
5785+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
5786+ code += vformat (" : instance_index(%d)" , get_instance_index ());
5787+ }
57625788 if (default_value_enabled) {
57635789 if (default_value) {
57645790 code += " = true" ;
@@ -5869,6 +5895,9 @@ Color VisualShaderNodeColorParameter::get_default_value() const {
58695895
58705896String VisualShaderNodeColorParameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
58715897 String code = _get_qual_str () + " uniform vec4 " + get_parameter_name () + " : source_color" ;
5898+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
5899+ code += vformat (" , instance_index(%d)" , get_instance_index ());
5900+ }
58725901 if (default_value_enabled) {
58735902 code += vformat (" = vec4(%.6f, %.6f, %.6f, %.6f)" , default_value.r , default_value.g , default_value.b , default_value.a );
58745903 }
@@ -5965,6 +5994,9 @@ Vector2 VisualShaderNodeVec2Parameter::get_default_value() const {
59655994
59665995String VisualShaderNodeVec2Parameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
59675996 String code = _get_qual_str () + " uniform vec2 " + get_parameter_name ();
5997+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
5998+ code += vformat (" : instance_index(%d)" , get_instance_index ());
5999+ }
59686000 if (default_value_enabled) {
59696001 code += vformat (" = vec2(%.6f, %.6f)" , default_value.x , default_value.y );
59706002 }
@@ -6065,6 +6097,9 @@ Vector3 VisualShaderNodeVec3Parameter::get_default_value() const {
60656097
60666098String VisualShaderNodeVec3Parameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
60676099 String code = _get_qual_str () + " uniform vec3 " + get_parameter_name ();
6100+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
6101+ code += vformat (" : instance_index(%d)" , get_instance_index ());
6102+ }
60686103 if (default_value_enabled) {
60696104 code += vformat (" = vec3(%.6f, %.6f, %.6f)" , default_value.x , default_value.y , default_value.z );
60706105 }
@@ -6165,6 +6200,9 @@ Vector4 VisualShaderNodeVec4Parameter::get_default_value() const {
61656200
61666201String VisualShaderNodeVec4Parameter::generate_global (Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
61676202 String code = _get_qual_str () + " uniform vec4 " + get_parameter_name ();
6203+ if (get_qualifier () == QUAL_INSTANCE_INDEX) {
6204+ code += vformat (" : instance_index(%d)" , get_instance_index ());
6205+ }
61686206 if (default_value_enabled) {
61696207 code += vformat (" = vec4(%.6f, %.6f, %.6f, %.6f)" , default_value.x , default_value.y , default_value.z , default_value.w );
61706208 }
@@ -6300,7 +6338,7 @@ bool VisualShaderNodeTransformParameter::is_use_prop_slots() const {
63006338}
63016339
63026340bool VisualShaderNodeTransformParameter::is_qualifier_supported (Qualifier p_qual) const {
6303- if (p_qual == Qualifier::QUAL_INSTANCE) {
6341+ if (p_qual == Qualifier::QUAL_INSTANCE || p_qual == Qualifier::QUAL_INSTANCE_INDEX ) {
63046342 return false ;
63056343 }
63066344 return true ;
@@ -6703,6 +6741,8 @@ bool VisualShaderNodeTextureParameter::is_qualifier_supported(Qualifier p_qual)
67036741 return true ;
67046742 case Qualifier::QUAL_INSTANCE:
67056743 return false ;
6744+ case Qualifier::QUAL_INSTANCE_INDEX:
6745+ return false ;
67066746 default :
67076747 break ;
67086748 }
0 commit comments