Skip to content

Commit

Permalink
[Rendering] Add hints to some uniform PropertyInfos
Browse files Browse the repository at this point in the history
* Enforce range on `int/uint`
* Use flags for `bvec2/3/4` arrays
  • Loading branch information
AThousandShips committed May 3, 2024
1 parent 34b5e8f commit 6ff6a11
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion servers/rendering/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4076,13 +4076,17 @@ 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;
}
break;
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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -4111,18 +4119,24 @@ 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;
case ShaderLanguage::TYPE_UVEC2:
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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 6ff6a11

Please sign in to comment.