MaterialX: add shader nodes #21

Merged
Bogdan Nagirniak merged 4 commits from matx-add-shader-nodes into matx-export-material 2023-09-14 16:55:15 +02:00
Showing only changes of commit e2e8f246e0 - Show all commits

View File

@ -29,6 +29,26 @@ static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_bsdf_translucent", in, out);
}
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
if (to_type_ != NodeItem::Type::BSDF) {
return empty();
}
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
NodeItem res = create_node("translucent_bsdf", NodeItem::Type::BSDF);
res.set_input("color", color * color);
if (normal) {
res.set_input("normal", normal);
}
return res;
}
#endif
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_bsdf_translucent_cc
/* node type definition */
@ -42,6 +62,7 @@ void register_node_type_sh_bsdf_translucent()
ntype.declare = file_ns::node_declare;
ntype.add_ui_poll = object_shader_nodes_poll;
ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_translucent;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype);
}