23 bool use_group_default)
25 graph,
depsgraph, material, node, socket_out,
to_type, group_parser, export_params),
26 use_group_default_(use_group_default)
35 ngroup->ensure_topology_cache();
36 const bNode *node_out = ngroup->group_output_node();
41 MaterialX::GraphElement *graph =
graph_;
42#ifdef USE_MATERIALX_NODEGRAPH
43 std::string name = MaterialX::createValidName(ngroup->
id.
name);
44 MaterialX::NodeGraphPtr group_graph =
graph_->getChildOfType<MaterialX::NodeGraph>(name);
47 group_graph =
graph_->addChild<MaterialX::NodeGraph>(name);
49 graph = group_graph.get();
63#ifdef USE_MATERIALX_NODEGRAPH
75 if (NodeItem::is_arithmetic(
to_type_)) {
83#ifdef USE_MATERIALX_NODEGRAPH
85 for (
auto socket_in :
node_->input_sockets()) {
89 value =
create_node(
"constant", value.type(), {{
"value", value}});
94 for (
int i = 0; i < values.size(); ++i) {
96 outputs.append(create_output(out_name(node_->input_sockets()[i]), values[i]));
99 return outputs[socket_out_->index()];
101 if (use_group_default_) {
102 return get_input_value(socket_out_->index(), to_type_);
104 return get_input_link(socket_out_->index(), to_type_);
114 node_->typeinfo->
type,
115 NodeItem::type(to_type_).c_str());
117#ifdef USE_MATERIALX_NODEGRAPH
121 res.
output = graph_->getOutput(out_name(socket_out_));
133std::string GroupOutputNodeParser::out_name(
const bNodeSocket *out_socket)
135 return MaterialX::createValidName(std::string(
"out_") + out_socket->
name);
140#ifdef USE_MATERIALX_NODEGRAPH
141 NodeItem value = group_parser_->get_input_link(socket_out_->index(), to_type_);
147 value = group_parser_->create_node(
"constant", value.type(), {{
"value", value}});
149 return create_input(in_name(), value);
151 if (use_group_default_) {
152 return group_parser_->get_input_value(socket_out_->index(), to_type_);
154 return group_parser_->get_input_link(socket_out_->index(), to_type_);
164 node_->typeinfo->
type,
165 NodeItem::type(to_type_).c_str());
167#ifdef USE_MATERIALX_NODEGRAPH
171 res.
input = graph_->getInput(in_name());
183std::string GroupInputNodeParser::in_name()
const
185 return MaterialX::createValidName(std::string(
"in_") + socket_out_->name);
#define CLOG_INFO(clg_ref, level,...)
NodeItem compute() override
NodeItem compute_full() override
GroupNodeParser(MaterialX::GraphElement *graph, const Depsgraph *depsgraph, const Material *material, const bNode *node, const bNodeSocket *socket_out, NodeItem::Type to_type, GroupNodeParser *group_parser, ExportParams export_params, bool use_group_default)
NodeItem compute_full() override
NodeItem compute() override
MaterialX::InputPtr input
MaterialX::OutputPtr output
NodeItem convert(Type to_type) const
NodeItem get_input_value(const std::string &name, NodeItem::Type to_type)
const bNodeSocket * socket_out_
MaterialX::GraphElement * graph_
const Material * material_
const Depsgraph * depsgraph_
ExportParams export_params_
NodeItem create_node(const std::string &category, NodeItem::Type type)
const Depsgraph * depsgraph
static Type to_type(const eGPUType type)
struct CLG_LogRef * LOG_MATERIALX_SHADER
static blender::bke::bNodeSocketTemplate outputs[]