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 } // namespace blender::nodes::materialx

View File

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

View File

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

View File

@ -26,4 +26,3 @@ class MaterialXNode {
}; };
} // namespace blender::nodes::materialx } // 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); MaterialX::Color3 default_white_color = MaterialX::Color3(1.0, 1.0, 1.0);
#pragma region get inputs #pragma region get inputs
const float *base_color = node->input_by_identifier("Base Color") const float *base_color =
.default_value_typed<bNodeSocketValueRGBA>() node->input_by_identifier("Base Color").default_value_typed<bNodeSocketValueRGBA>()->value;
->value;
const float subsurface = 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") const float *subsurface_radius = node->input_by_identifier("Subsurface Radius")
.default_value_typed<bNodeSocketValueVector>() .default_value_typed<bNodeSocketValueVector>()
->value; ->value;
const float *subsurface_color = node->input_by_identifier("Subsurface Color") const float *subsurface_color = node->input_by_identifier("Subsurface Color")
.default_value_typed<bNodeSocketValueRGBA>() .default_value_typed<bNodeSocketValueRGBA>()
->value; ->value;
const float metallic = node->input_by_identifier("Metallic").default_value_typed<bNodeSocketValueFloat>() const float metallic =
->value; node->input_by_identifier("Metallic").default_value_typed<bNodeSocketValueFloat>()->value;
const float specular = const float specular =
node->input_by_identifier("Specular").default_value_typed<bNodeSocketValueFloat>() node->input_by_identifier("Specular").default_value_typed<bNodeSocketValueFloat>()->value;
->value;
const float roughness = const float roughness =
node->input_by_identifier("Roughness").default_value_typed<bNodeSocketValueFloat>() node->input_by_identifier("Roughness").default_value_typed<bNodeSocketValueFloat>()->value;
->value;
const float anisotropic = const float anisotropic =
node->input_by_identifier("Anisotropic").default_value_typed<bNodeSocketValueFloat>() node->input_by_identifier("Anisotropic").default_value_typed<bNodeSocketValueFloat>()->value;
->value; const float anisotropic_rot = node->input_by_identifier("Anisotropic Rotation")
const float anisotropic_rot = .default_value_typed<bNodeSocketValueFloat>()
node->input_by_identifier("Anisotropic Rotation").default_value_typed<bNodeSocketValueFloat>() ->value;
->value;
const float sheen = const float sheen =
node->input_by_identifier("Sheen").default_value_typed<bNodeSocketValueFloat>() node->input_by_identifier("Sheen").default_value_typed<bNodeSocketValueFloat>()->value;
->value;
const float clearcoat = const float clearcoat =
node->input_by_identifier("Clearcoat").default_value_typed<bNodeSocketValueFloat>() node->input_by_identifier("Clearcoat").default_value_typed<bNodeSocketValueFloat>()->value;
->value; const float clearcoat_roughness = node->input_by_identifier("Clearcoat Roughness")
const float clearcoat_roughness = .default_value_typed<bNodeSocketValueFloat>()
node->input_by_identifier("Clearcoat Roughness").default_value_typed<bNodeSocketValueFloat>() ->value;
->value;
const float IOR = const float IOR =
node->input_by_identifier("IOR").default_value_typed<bNodeSocketValueFloat>() node->input_by_identifier("IOR").default_value_typed<bNodeSocketValueFloat>()->value;
->value; const float transmission = node->input_by_identifier("Transmission")
const float transmission = .default_value_typed<bNodeSocketValueFloat>()
node->input_by_identifier("Transmission").default_value_typed<bNodeSocketValueFloat>() ->value;
->value;
const float *emission = const float *emission =
node->input_by_identifier("Emission").default_value_typed<bNodeSocketValueRGBA>() node->input_by_identifier("Emission").default_value_typed<bNodeSocketValueRGBA>()->value;
->value;
const float emission_str = node->input_by_identifier("Emission Strength") const float emission_str = node->input_by_identifier("Emission Strength")
.default_value_typed<bNodeSocketValueFloat>() .default_value_typed<bNodeSocketValueFloat>()
->value; ->value;
const float *normal = const float *normal =
node->input_by_identifier("Normal").default_value_typed<bNodeSocketValueVector>() node->input_by_identifier("Normal").default_value_typed<bNodeSocketValueVector>()->value;
->value; const float *clearcoat_normal = node->input_by_identifier("Clearcoat Normal")
const float *clearcoat_normal = .default_value_typed<bNodeSocketValueVector>()
node->input_by_identifier("Clearcoat Normal").default_value_typed<bNodeSocketValueVector>() ->value;
->value;
const float *tangent = const float *tangent =
node->input_by_identifier("Tangent").default_value_typed<bNodeSocketValueVector>() node->input_by_identifier("Tangent").default_value_typed<bNodeSocketValueVector>()->value;
->value;
#pragma endregion get inputs #pragma endregion get inputs
#pragma region set inputs #pragma region set inputs
matx_node->addInput("base", "float")->setValue(1.0); 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("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") matx_node->addInput("tangent", "vector3")
->setValue(MaterialX::Vector3(tangent[0], tangent[1], tangent[2])); ->setValue(MaterialX::Vector3(tangent[0], tangent[1], tangent[2]));
@ -106,21 +98,21 @@ MaterialX::NodePtr MaterialXPrincipledBSDFNode::convert()
->setValue( ->setValue(
MaterialX::Color3(subsurface_radius[0], subsurface_radius[1], subsurface_radius[2])); MaterialX::Color3(subsurface_radius[0], subsurface_radius[1], subsurface_radius[2]));
matx_node->addInput("subsurface_anisotropy", "float")->setValue(anisotropic); matx_node->addInput("subsurface_anisotropy", "float")->setValue(anisotropic);
matx_node->addInput("sheen", "float")->setValue(sheen); matx_node->addInput("sheen", "float")->setValue(sheen);
matx_node->addInput("sheen_color", "color3")->setValue(default_white_color); matx_node->addInput("sheen_color", "color3")->setValue(default_white_color);
matx_node->addInput("sheen_roughness", "float")->setValue(roughness); matx_node->addInput("sheen_roughness", "float")->setValue(roughness);
matx_node->addInput("coat", "float")->setValue(clearcoat); matx_node->addInput("coat", "float")->setValue(clearcoat);
matx_node->addInput("coat_color", "color3")->setValue(default_white_color); matx_node->addInput("coat_color", "color3")->setValue(default_white_color);
matx_node->addInput("coat_roughness", "float")->setValue(clearcoat_roughness); matx_node->addInput("coat_roughness", "float")->setValue(clearcoat_roughness);
matx_node->addInput("coat_IOR", "float")->setValue(IOR); matx_node->addInput("coat_IOR", "float")->setValue(IOR);
matx_node->addInput("coat_anisotropy", "float")->setValue(anisotropic); matx_node->addInput("coat_anisotropy", "float")->setValue(anisotropic);
matx_node->addInput("coat_rotation", "float")->setValue(anisotropic_rot); matx_node->addInput("coat_rotation", "float")->setValue(anisotropic_rot);
matx_node->addInput("coat_normal", "vector3") matx_node->addInput("coat_normal", "vector3")
->setValue( ->setValue(
MaterialX::Vector3(clearcoat_normal[0], clearcoat_normal[1], clearcoat_normal[2])); MaterialX::Vector3(clearcoat_normal[0], clearcoat_normal[1], clearcoat_normal[2]));
matx_node->addInput("emission", "float")->setValue(emission_str); matx_node->addInput("emission", "float")->setValue(emission_str);
matx_node->addInput("emission_color", "color3") matx_node->addInput("emission_color", "color3")
->setValue(MaterialX::Color3(emission[0], emission[1], emission[2])); ->setValue(MaterialX::Color3(emission[0], emission[1], emission[2]));
@ -129,4 +121,3 @@ MaterialX::NodePtr MaterialXPrincipledBSDFNode::convert()
} }
} // namespace blender::nodes::materialx } // namespace blender::nodes::materialx

View File

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