MaterialX: add support for Vector nodes #27

Merged
Bogdan Nagirniak merged 13 commits from Vasyl-Pidhirskyi/blender:BLEN-525 into matx-export-material 2023-09-22 10:03:45 +02:00
3 changed files with 22 additions and 0 deletions
Showing only changes of commit c103e4faa3 - Show all commits

View File

@ -53,6 +53,9 @@ NodeItem::Type NodeItem::type(const std::string &type_str)
if (type_str == "EDF") { if (type_str == "EDF") {
return Type::EDF; return Type::EDF;
} }
if (type_str == "displacementshader") {
return Type::Displacementshader;
}
if (type_str == "surfaceshader") { if (type_str == "surfaceshader") {
return Type::SurfaceShader; return Type::SurfaceShader;
} }
@ -94,6 +97,8 @@ std::string NodeItem::type(Type type)
return "BSDF"; return "BSDF";
case Type::EDF: case Type::EDF:
return "EDF"; return "EDF";
case Type::Displacementshader:
return "displacementshader";
case Type::SurfaceShader: case Type::SurfaceShader:
return "surfaceshader"; return "surfaceshader";
case Type::Material: case Type::Material:

View File

@ -39,6 +39,7 @@ class NodeItem {
* NOTE: There are only supported types */ * NOTE: There are only supported types */
BSDF, BSDF,
EDF, EDF,
Displacementshader,
SurfaceShader, SurfaceShader,
Material, Material,
}; };

View File

@ -41,6 +41,21 @@ static int gpu_shader_vector_displacement(GPUMaterial *mat,
} }
} }
NODE_SHADER_MATERIALX_BEGIN
{
/* NOTE: Space feature don't have an implementation in MaterialX.*/
NodeItem midlevel = get_input_value("midlevel", NodeItem::Type::Float);
NodeItem vector = get_input_link("Vector", NodeItem::Type::Vector3);
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
NodeItem res = create_node("displacement", NodeItem::Type::Displacementshader);
res.set_input("displacement", vector);
res.set_input("scale", scale);
return res;
}
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_vector_displacement_cc } // namespace blender::nodes::node_shader_vector_displacement_cc
/* node type definition */ /* node type definition */
@ -55,6 +70,7 @@ void register_node_type_sh_vector_displacement()
ntype.declare = file_ns::node_declare; ntype.declare = file_ns::node_declare;
ntype.initfunc = file_ns::node_shader_init_vector_displacement; ntype.initfunc = file_ns::node_shader_init_vector_displacement;
ntype.gpu_fn = file_ns::gpu_shader_vector_displacement; ntype.gpu_fn = file_ns::gpu_shader_vector_displacement;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }