MaterialX: add support for nodes #11

Merged
Bogdan Nagirniak merged 17 commits from matx-add-other-nodes into matx-export-material 2023-09-06 10:37:26 +02:00
Showing only changes of commit b220d429d7 - Show all commits

View File

@ -19,12 +19,12 @@ NodeItem SeparateColorNodeParser::compute()
break;
case NODE_COMBSEP_COLOR_HSV:
convert = create_node("rgbtohsv", "color3");
convert.set_input("in", color, NodeItem::Type::Color3);
convert.set_input("in", color);
break;
case NODE_COMBSEP_COLOR_HSL:
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
convert = create_node("rgbtohsv", "color3");
convert.set_input("in", color, NodeItem::Type::Color3);
convert.set_input("in", color);
break;
default:
BLI_assert_unreachable();
@ -38,8 +38,35 @@ NodeItem SeparateColorNodeParser::compute()
NodeItem CombineColorNodeParser::compute()
{
/* TODO: implement. */
return empty();
int mode = static_cast<NodeCombSepColor *>(node_->storage)->mode;
NodeItem red = get_input_value("Red");
NodeItem green = get_input_value("Green");
NodeItem blue = get_input_value("Blue");
NodeItem convert = empty();
NodeItem combine = create_node("combine3", "color3");
combine.set_input("in1", red);
combine.set_input("in2", green);
combine.set_input("in3", blue);
switch (mode) {
case NODE_COMBSEP_COLOR_RGB:
break;
case NODE_COMBSEP_COLOR_HSV:
convert = create_node("hsvtorgb", "color3");
convert.set_input("in", combine);
break;
case NODE_COMBSEP_COLOR_HSL:
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
convert = create_node("hsvtorgb", "color3");
convert.set_input("in", combine);
break;
default:
BLI_assert_unreachable();
}
NodeItem res = convert ? convert : combine;
return res;
}
} // namespace blender::nodes::materialx