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 fef443c5aa - Show all commits

View File

@ -71,6 +71,30 @@ static int gpu_shader_bump(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_bump", in, out, dheight, GPU_constant(&invert)); return GPU_stack_link(mat, node, "node_bump", in, out, dheight, GPU_constant(&invert));
} }
NODE_SHADER_MATERIALX_BEGIN
{
NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
NodeItem distance = get_input_value("Distance", NodeItem::Type::Float);
NodeItem height = get_input_link("Height", NodeItem::Type::Float);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
if (node_->custom1) {
distance = distance * val(-1.0f);
}
NodeItem height_normal = create_node("heighttonormal", NodeItem::Type::Vector3);
height_normal.set_input("in", height);
height_normal.set_input("scale", strength);
NodeItem res = create_node("normalmap", NodeItem::Type::Vector3);
res.set_input("in", height_normal);
res.set_input("scale", distance);
res.set_input("normal", normal);
return res;
}
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_bump_cc } // namespace blender::nodes::node_shader_bump_cc
/* node type definition */ /* node type definition */
@ -84,6 +108,7 @@ void register_node_type_sh_bump()
ntype.declare = file_ns::node_declare; ntype.declare = file_ns::node_declare;
ntype.draw_buttons = file_ns::node_shader_buts_bump; ntype.draw_buttons = file_ns::node_shader_buts_bump;
ntype.gpu_fn = file_ns::gpu_shader_bump; ntype.gpu_fn = file_ns::gpu_shader_bump;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }