|
|
@ -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]));
|
|
|
|
|
|
|
|
|
|
|
@ -129,4 +121,3 @@ MaterialX::NodePtr MaterialXPrincipledBSDFNode::convert()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace blender::nodes::materialx
|
|
|
|
} // namespace blender::nodes::materialx
|
|
|
|
|
|
|
|
|
|
|
|