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
Showing only changes of commit 8e91ff2468 - Show all commits

View File

@ -37,6 +37,21 @@ static int gpu_shader_displacement(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_displacement_world", in, out); return GPU_stack_link(mat, node, "node_displacement_world", in, out);
} }
NODE_SHADER_MATERIALX_BEGIN
{
/* NOTE: Normal input and Space feature don't have an implementation in MaterialX.*/
NodeItem midlevel = get_input_value("Midlevel", NodeItem::Type::Float);
NodeItem height = get_input_value("Height", NodeItem::Type::Float) - midlevel;
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
NodeItem res = create_node("displacement", NodeItem::Type::Displacementshader);
res.set_input("displacement", height);
res.set_input("scale", scale);
return res;
}
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_displacement_cc } // namespace blender::nodes::node_shader_displacement_cc
/* node type definition */ /* node type definition */
@ -50,6 +65,7 @@ void register_node_type_sh_displacement()
ntype.declare = file_ns::node_declare; ntype.declare = file_ns::node_declare;
ntype.initfunc = file_ns::node_shader_init_displacement; ntype.initfunc = file_ns::node_shader_init_displacement;
ntype.gpu_fn = file_ns::gpu_shader_displacement; ntype.gpu_fn = file_ns::gpu_shader_displacement;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }