MaterialX: Implement export of Input nodes #20

Merged
Bogdan Nagirniak merged 26 commits from Vasyl-Pidhirskyi/blender:BLEN-530 into matx-export-material 2023-09-15 19:55:37 +02:00
2 changed files with 27 additions and 2 deletions
Showing only changes of commit 891c3c0966 - Show all commits

View File

@ -34,7 +34,7 @@ NodeItem NodeParser::compute_full()
/* Checking if node was already computed */
res.node = graph_->getNode(node_name());
if (res.node) {
return res;
return res.convert(to_type_);
}
CLOG_INFO(LOG_MATERIALX_SHADER,
@ -101,6 +101,16 @@ NodeItem NodeParser::get_input_value(int index, NodeItem::Type to_type)
return get_input_value(node_->input_socket(index), to_type);
}
NodeItem NodeParser::get_output_default(const std::string &name)
{
return get_output_default(node_->output_by_identifier(name));
}
NodeItem NodeParser::get_output_default(int index)
{
return get_output_default(node_->output_socket(index));
}
NodeItem NodeParser::empty() const
{
return NodeItem(graph_);
@ -118,6 +128,17 @@ NodeItem NodeParser::texcoord_node()
}
NodeItem NodeParser::get_input_default(const bNodeSocket &socket, NodeItem::Type to_type)
{
NodeItem res = get_value_default(socket);
return res.convert(to_type);
}
NodeItem NodeParser::get_output_default(const bNodeSocket &socket)
{
return get_value_default(socket);
}
NodeItem NodeParser::get_value_default(const bNodeSocket &socket)
{
NodeItem res = empty();
switch (socket.type) {
@ -142,7 +163,7 @@ NodeItem NodeParser::get_input_default(const bNodeSocket &socket, NodeItem::Type
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported socket type: %d", socket.type);
}
}
return res.convert(to_type);
Vasyl-Pidhirskyi marked this conversation as resolved Outdated

I think this has to be reverted back, let to_type be here. It is always possible to use Type::Any

I think this has to be reverted back, let to_type be here. It is always possible to use Type::Any
return res;
}
NodeItem NodeParser::get_input_link(const bNodeSocket &socket, NodeItem::Type to_type)

View File

@ -42,6 +42,8 @@ class NodeParser {
NodeItem create_node(const std::string &category, NodeItem::Type type);
NodeItem get_input_default(const std::string &name, NodeItem::Type to_type);
NodeItem get_input_default(int index, NodeItem::Type to_type);
NodeItem get_output_default(const std::string &name);
NodeItem get_output_default(int index);
NodeItem get_input_link(const std::string &name, NodeItem::Type to_type);
NodeItem get_input_link(int index, NodeItem::Type to_type);
NodeItem get_input_value(const std::string &name, NodeItem::Type to_type);
@ -52,6 +54,8 @@ class NodeParser {
private:
NodeItem get_input_default(const bNodeSocket &socket, NodeItem::Type to_type);
NodeItem get_output_default(const bNodeSocket &socket);
NodeItem get_value_default(const bNodeSocket &socket);
BogdanNagirniak marked this conversation as resolved Outdated

use one function here instead of 3 get_default(const bNodeSocket &socket, NodeItem::Type to_type)

use one function here instead of 3 `get_default(const bNodeSocket &socket, NodeItem::Type to_type)`
NodeItem get_input_link(const bNodeSocket &socket, NodeItem::Type to_type);
NodeItem get_input_value(const bNodeSocket &socket, NodeItem::Type to_type);
};