forked from blender/blender
matx-extend-create_node #25
@ -61,9 +61,7 @@ NodeItem GroupOutputNodeParser::compute()
|
|||||||
for (auto socket_in : node_->input_sockets()) {
|
for (auto socket_in : node_->input_sockets()) {
|
||||||
NodeItem value = get_input_value(socket_in->index(), NodeItem::Type::Any);
|
NodeItem value = get_input_value(socket_in->index(), NodeItem::Type::Any);
|
||||||
if (value.value) {
|
if (value.value) {
|
||||||
NodeItem constant = create_node("constant", value.type());
|
value = create_node("constant", value.type(), {{"value", value}});
|
||||||
constant.set_input("value", value);
|
|
||||||
value = constant;
|
|
||||||
}
|
}
|
||||||
values.append(value);
|
values.append(value);
|
||||||
}
|
}
|
||||||
@ -113,9 +111,7 @@ NodeItem GroupInputNodeParser::compute()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value.value) {
|
if (value.value) {
|
||||||
NodeItem constant = create_node("constant", value.type());
|
value = create_node("constant", value.type(), {{"value", value}});
|
||||||
constant.set_input("value", value);
|
|
||||||
value = constant;
|
|
||||||
}
|
}
|
||||||
return create_input("input" + std::to_string(socket_out_->index() + 1), value);
|
return create_input("input" + std::to_string(socket_out_->index() + 1), value);
|
||||||
#else
|
#else
|
||||||
|
@ -21,10 +21,12 @@ class DefaultMaterialNodeParser : public NodeParser {
|
|||||||
|
|
||||||
NodeItem compute() override
|
NodeItem compute() override
|
||||||
{
|
{
|
||||||
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
NodeItem surface = create_node(
|
||||||
surface.set_input("base_color",
|
"standard_surface",
|
||||||
val(MaterialX::Color3(material_->r, material_->g, material_->b)));
|
NodeItem::Type::SurfaceShader,
|
||||||
surface.set_input("diffuse_roughness", val(material_->roughness));
|
{{"base_color", val(MaterialX::Color3(material_->r, material_->g, material_->b))},
|
||||||
|
{"diffuse_roughness", val(material_->roughness)}});
|
||||||
|
|
||||||
if (material_->metallic > 0.0f) {
|
if (material_->metallic > 0.0f) {
|
||||||
surface.set_input("metalness", val(material_->metallic));
|
surface.set_input("metalness", val(material_->metallic));
|
||||||
}
|
}
|
||||||
@ -34,20 +36,20 @@ class DefaultMaterialNodeParser : public NodeParser {
|
|||||||
surface.set_input("specular_roughness", val(material_->roughness));
|
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.node->setName("Material_Default");
|
||||||
res.set_input("surfaceshader", surface);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem compute_error()
|
NodeItem compute_error()
|
||||||
{
|
{
|
||||||
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
NodeItem surface = create_node("standard_surface",
|
||||||
surface.set_input("base_color", val(MaterialX::Color3(1.0f, 0.0f, 1.0f)));
|
NodeItem::Type::SurfaceShader,
|
||||||
|
{{"base_color", val(MaterialX::Color3(1.0f, 0.0f, 1.0f))}});
|
||||||
NodeItem res = create_node("surfacematerial", NodeItem::Type::Material);
|
NodeItem res = create_node(
|
||||||
|
"surfacematerial", NodeItem::Type::Material, {{"surfaceshader", surface}});
|
||||||
res.node->setName("Material_Error");
|
res.node->setName("Material_Error");
|
||||||
res.set_input("surfaceshader", surface);
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user