Add basic supported nodes #1

Merged
Bogdan Nagirniak merged 5 commits from add-basic-nodes into matx-export-material 2023-08-24 10:23:00 +02:00
6 changed files with 39 additions and 53 deletions
Showing only changes of commit 3b8534b416 - Show all commits

View File

@ -32,4 +32,3 @@ MaterialX::NodePtr MaterialXMaterialOutputNode::convert()
}
} // namespace blender::nodes::materialx

View File

@ -17,4 +17,3 @@ class MaterialXMaterialOutputNode : public MaterialXNode {
};
} // namespace blender::nodes::materialx

View File

@ -14,4 +14,3 @@ MaterialXNode::MaterialXNode(MaterialX::DocumentPtr doc,
}
} // namespace blender::nodes::materialx

View File

@ -26,4 +26,3 @@ class MaterialXNode {
};
} // namespace blender::nodes::materialx

View File

@ -20,69 +20,61 @@ MaterialX::NodePtr MaterialXPrincipledBSDFNode::convert()
{
MaterialX::Color3 default_white_color = MaterialX::Color3(1.0, 1.0, 1.0);
#pragma region get inputs
const float *base_color = node->input_by_identifier("Base Color")
.default_value_typed<bNodeSocketValueRGBA>()
->value;
const float *base_color =
node->input_by_identifier("Base Color").default_value_typed<bNodeSocketValueRGBA>()->value;
const float subsurface =
node->input_by_identifier("Subsurface").default_value_typed<bNodeSocketValueFloat>()->value;
node->input_by_identifier("Subsurface").default_value_typed<bNodeSocketValueFloat>()->value;
const float *subsurface_radius = node->input_by_identifier("Subsurface Radius")
.default_value_typed<bNodeSocketValueVector>()
->value;
.default_value_typed<bNodeSocketValueVector>()
->value;
const float *subsurface_color = node->input_by_identifier("Subsurface Color")
.default_value_typed<bNodeSocketValueRGBA>()
->value;
const float metallic = node->input_by_identifier("Metallic").default_value_typed<bNodeSocketValueFloat>()
->value;
.default_value_typed<bNodeSocketValueRGBA>()
->value;
const float metallic =
node->input_by_identifier("Metallic").default_value_typed<bNodeSocketValueFloat>()->value;
const float specular =
node->input_by_identifier("Specular").default_value_typed<bNodeSocketValueFloat>()
->value;
node->input_by_identifier("Specular").default_value_typed<bNodeSocketValueFloat>()->value;
const float roughness =
node->input_by_identifier("Roughness").default_value_typed<bNodeSocketValueFloat>()
->value;
node->input_by_identifier("Roughness").default_value_typed<bNodeSocketValueFloat>()->value;
const float anisotropic =
node->input_by_identifier("Anisotropic").default_value_typed<bNodeSocketValueFloat>()
->value;
const float anisotropic_rot =
node->input_by_identifier("Anisotropic Rotation").default_value_typed<bNodeSocketValueFloat>()
->value;
node->input_by_identifier("Anisotropic").default_value_typed<bNodeSocketValueFloat>()->value;
const float anisotropic_rot = node->input_by_identifier("Anisotropic Rotation")
.default_value_typed<bNodeSocketValueFloat>()
->value;
const float sheen =
node->input_by_identifier("Sheen").default_value_typed<bNodeSocketValueFloat>()
->value;
node->input_by_identifier("Sheen").default_value_typed<bNodeSocketValueFloat>()->value;
const float clearcoat =
node->input_by_identifier("Clearcoat").default_value_typed<bNodeSocketValueFloat>()
->value;
const float clearcoat_roughness =
node->input_by_identifier("Clearcoat Roughness").default_value_typed<bNodeSocketValueFloat>()
->value;
node->input_by_identifier("Clearcoat").default_value_typed<bNodeSocketValueFloat>()->value;
const float clearcoat_roughness = node->input_by_identifier("Clearcoat Roughness")
.default_value_typed<bNodeSocketValueFloat>()
->value;
const float IOR =
node->input_by_identifier("IOR").default_value_typed<bNodeSocketValueFloat>()
->value;
const float transmission =
node->input_by_identifier("Transmission").default_value_typed<bNodeSocketValueFloat>()
->value;
node->input_by_identifier("IOR").default_value_typed<bNodeSocketValueFloat>()->value;
const float transmission = node->input_by_identifier("Transmission")
.default_value_typed<bNodeSocketValueFloat>()
->value;
const float *emission =
node->input_by_identifier("Emission").default_value_typed<bNodeSocketValueRGBA>()
->value;
node->input_by_identifier("Emission").default_value_typed<bNodeSocketValueRGBA>()->value;
const float emission_str = node->input_by_identifier("Emission Strength")
.default_value_typed<bNodeSocketValueFloat>()
->value;
.default_value_typed<bNodeSocketValueFloat>()
->value;
const float *normal =
node->input_by_identifier("Normal").default_value_typed<bNodeSocketValueVector>()
->value;
const float *clearcoat_normal =
node->input_by_identifier("Clearcoat Normal").default_value_typed<bNodeSocketValueVector>()
->value;
node->input_by_identifier("Normal").default_value_typed<bNodeSocketValueVector>()->value;
const float *clearcoat_normal = node->input_by_identifier("Clearcoat Normal")
.default_value_typed<bNodeSocketValueVector>()
->value;
const float *tangent =
node->input_by_identifier("Tangent").default_value_typed<bNodeSocketValueVector>()
->value;
node->input_by_identifier("Tangent").default_value_typed<bNodeSocketValueVector>()->value;
#pragma endregion get inputs
#pragma region set inputs
matx_node->addInput("base", "float")->setValue(1.0);
matx_node->addInput("base_color", "color3")->setValue(MaterialX::Color3(base_color[0], base_color[1], base_color[2]));
matx_node->addInput("base_color", "color3")
->setValue(MaterialX::Color3(base_color[0], base_color[1], base_color[2]));
matx_node->addInput("diffuse_roughness", "float")->setValue(roughness);
matx_node->addInput("normal", "vector3")->setValue(MaterialX::Vector3(normal[0], normal[1], normal[2]));
matx_node->addInput("normal", "vector3")
->setValue(MaterialX::Vector3(normal[0], normal[1], normal[2]));
matx_node->addInput("tangent", "vector3")
->setValue(MaterialX::Vector3(tangent[0], tangent[1], tangent[2]));
@ -129,4 +121,3 @@ MaterialX::NodePtr MaterialXPrincipledBSDFNode::convert()
}
} // namespace blender::nodes::materialx

View File

@ -17,4 +17,3 @@ class MaterialXPrincipledBSDFNode : public MaterialXNode {
};
} // namespace blender::nodes::materialx