matx-extend-create_node #25

Merged
Bogdan Nagirniak merged 4 commits from BogdanNagirniak/blender:matx-extend-create_node into matx-export-material 2023-09-19 18:28:04 +02:00
2 changed files with 15 additions and 17 deletions
Showing only changes of commit 00ee44e9de - Show all commits

View File

@ -61,9 +61,7 @@ NodeItem GroupOutputNodeParser::compute()
for (auto socket_in : node_->input_sockets()) {
NodeItem value = get_input_value(socket_in->index(), NodeItem::Type::Any);
if (value.value) {
NodeItem constant = create_node("constant", value.type());
constant.set_input("value", value);
value = constant;
value = create_node("constant", value.type(), {{"value", value}});
}
values.append(value);
}
@ -113,9 +111,7 @@ NodeItem GroupInputNodeParser::compute()
}
if (value.value) {
NodeItem constant = create_node("constant", value.type());
constant.set_input("value", value);
value = constant;
value = create_node("constant", value.type(), {{"value", value}});
}
return create_input("input" + std::to_string(socket_out_->index() + 1), value);
#else

View File

@ -21,10 +21,12 @@ class DefaultMaterialNodeParser : public NodeParser {
NodeItem compute() override
{
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
surface.set_input("base_color",
val(MaterialX::Color3(material_->r, material_->g, material_->b)));
surface.set_input("diffuse_roughness", val(material_->roughness));
NodeItem surface = create_node(
"standard_surface",
NodeItem::Type::SurfaceShader,
{{"base_color", val(MaterialX::Color3(material_->r, material_->g, material_->b))},
{"diffuse_roughness", val(material_->roughness)}});
if (material_->metallic > 0.0f) {
surface.set_input("metalness", val(material_->metallic));
}
@ -34,20 +36,20 @@ class DefaultMaterialNodeParser : public NodeParser {
surface.set_input("specular_roughness", val(material_->roughness));
}
NodeItem res = create_node("surfacematerial", NodeItem::Type::Material);
NodeItem res = create_node(
"surfacematerial", NodeItem::Type::Material, {{"surfaceshader", surface}});
res.node->setName("Material_Default");
res.set_input("surfaceshader", surface);
return res;
}
NodeItem compute_error()
{
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
surface.set_input("base_color", val(MaterialX::Color3(1.0f, 0.0f, 1.0f)));
NodeItem res = create_node("surfacematerial", NodeItem::Type::Material);
NodeItem surface = create_node("standard_surface",
NodeItem::Type::SurfaceShader,
{{"base_color", val(MaterialX::Color3(1.0f, 0.0f, 1.0f))}});
NodeItem res = create_node(
"surfacematerial", NodeItem::Type::Material, {{"surfaceshader", surface}});
res.node->setName("Material_Error");
res.set_input("surfaceshader", surface);
return res;
}
};