Merge pull request #89488 from AThousandShips/shader_hint_fix

[Rendering] Add hints to some uniform `PropertyInfo`s
This commit is contained in:
Rémi Verschelde 2024-05-03 10:31:38 +02:00
commit fa3ad278a1
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 17 additions and 1 deletions

View File

@ -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;
if (p_uniform.hint == ShaderLanguage::ShaderNode::Uniform::HINT_RANGE) {
pi.hint = PROPERTY_HINT_RANGE;
if (p_uniform.hint == ShaderLanguage::ShaderNode::Uniform::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;
}