From 6ff6a11424659efaf7dc6a34e003b84d5e15dcd3 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Thu, 14 Mar 2024 19:15:46 +0100 Subject: [PATCH] [Rendering] Add hints to some uniform `PropertyInfo`s * Enforce range on `int/uint` * Use flags for `bvec2/3/4` arrays --- servers/rendering/shader_language.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 99b3f54379e..65f147a8dc4 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -4076,6 +4076,8 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_BOOL: if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + pi.hint = PROPERTY_HINT_TYPE_STRING; + pi.hint_string = itos(Variant::INT) + "/" + itos(PROPERTY_HINT_FLAGS) + ":" + RTR("On"); } else { pi.type = Variant::BOOL; } @@ -4083,6 +4085,8 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_BVEC2: if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + pi.hint = PROPERTY_HINT_TYPE_STRING; + pi.hint_string = itos(Variant::INT) + "/" + itos(PROPERTY_HINT_FLAGS) + ":x,y"; } else { pi.type = Variant::INT; pi.hint = PROPERTY_HINT_FLAGS; @@ -4092,6 +4096,8 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_BVEC3: if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + pi.hint = PROPERTY_HINT_TYPE_STRING; + pi.hint_string = itos(Variant::INT) + "/" + itos(PROPERTY_HINT_FLAGS) + ":x,y,z"; } else { pi.type = Variant::INT; pi.hint = PROPERTY_HINT_FLAGS; @@ -4101,6 +4107,8 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_BVEC4: if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + pi.hint = PROPERTY_HINT_TYPE_STRING; + pi.hint_string = itos(Variant::INT) + "/" + itos(PROPERTY_HINT_FLAGS) + ":x,y,z,w"; } else { pi.type = Variant::INT; pi.hint = PROPERTY_HINT_FLAGS; @@ -4111,11 +4119,16 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_INT: { if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + // TODO: Handle range and encoding for for unsigned values. } else { pi.type = Variant::INT; + pi.hint = PROPERTY_HINT_RANGE; if (p_uniform.hint == ShaderLanguage::ShaderNode::Uniform::HINT_RANGE) { - pi.hint = PROPERTY_HINT_RANGE; pi.hint_string = rtos(p_uniform.hint_range[0]) + "," + rtos(p_uniform.hint_range[1]) + "," + rtos(p_uniform.hint_range[2]); + } else if (p_uniform.type == ShaderLanguage::TYPE_UINT) { + pi.hint_string = "0," + itos(UINT32_MAX); + } else { + pi.hint_string = itos(INT32_MIN) + "," + itos(INT32_MAX); } } } break; @@ -4123,6 +4136,7 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_IVEC2: { if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + // TODO: Handle vector pairs? } else { pi.type = Variant::VECTOR2I; } @@ -4131,6 +4145,7 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_IVEC3: { if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + // TODO: Handle vector pairs? } else { pi.type = Variant::VECTOR3I; } @@ -4139,6 +4154,7 @@ PropertyInfo ShaderLanguage::uniform_to_property_info(const ShaderNode::Uniform case ShaderLanguage::TYPE_IVEC4: { if (p_uniform.array_size > 0) { pi.type = Variant::PACKED_INT32_ARRAY; + // TODO: Handle vector pairs? } else { pi.type = Variant::VECTOR4I; }