MaterialX: add convert nodes #15

Merged
Bogdan Nagirniak merged 8 commits from matx-add-convert-nodes into matx-export-material 2023-09-08 16:55:00 +02:00
3 changed files with 17 additions and 9 deletions
Showing only changes of commit 33d2cfc8b0 - Show all commits

View File

@ -8,11 +8,15 @@ namespace blender::nodes::materialx {
NodeItem BlackbodyNodeParser::compute()
{
NodeItem temperature = get_input_value("Temperature", NodeItem::Type::Float);
/* This node doesn't have an implementation in MaterialX 1.38.6.
* It's added in MaterialX 1.38.8. Uncomment this code after switching to 1.38.8.
BogdanNagirniak marked this conversation as resolved Outdated

It is exists in pbrlib_def.mtlx, can be used here

It is exists in pbrlib_def.mtlx, can be used here
*
* NodeItem temperature = get_input_value("Temperature", NodeItem::Type::Float);
NodeItem res = create_node("blackbody", NodeItem::Type::Color3);
res.set_input("temperature", temperature);
return res;
* NodeItem res = create_node("blackbody", NodeItem::Type::Color3);
* res.set_input("temperature", temperature);
* return res; */
return empty();
}
} // namespace blender::nodes::materialx

View File

@ -13,11 +13,15 @@ NodeItem ClampNodeParser::compute()
NodeItem min = get_input_value("Min", NodeItem::Type::Float);
NodeItem max = get_input_value("Max", NodeItem::Type::Float);
if (type == NODE_CLAMP_MINMAX) {
min = min.if_else(NodeItem::CompareOp::Greater, max, max, min);
NodeItem res = empty();
if (type == NODE_CLAMP_RANGE) {
BogdanNagirniak marked this conversation as resolved Outdated

min = min.min(max)

`min = min.min(max)`
res = min.if_else(
NodeItem::CompareOp::Less, max, value.clamp(min, max), value.clamp(max, min));
BogdanNagirniak marked this conversation as resolved Outdated

does it correctly work with RANGE? do we need swap min max if min > max?

does it correctly work with RANGE? do we need swap min max if min > max?
}
return value.clamp(min, max);
else {
res = value.clamp(min, max);
}
return res;
}
} // namespace blender::nodes::materialx

View File

@ -12,7 +12,7 @@ NodeItem RGBToBWNodeParser::compute()
NodeItem res = create_node("luminance", NodeItem::Type::Color4);
res.set_input("in", color);
return res;
return res;
}
} // namespace blender::nodes::materialx