MaterialX: Implement export of Input nodes #20

Merged
Bogdan Nagirniak merged 26 commits from Vasyl-Pidhirskyi/blender:BLEN-530 into matx-export-material 2023-09-15 19:55:37 +02:00
3 changed files with 73 additions and 0 deletions
Showing only changes of commit c1762e955e - Show all commits

View File

@ -47,6 +47,29 @@ static int node_shader_gpu_bsdf_sheen(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_bsdf_sheen", in, out); return GPU_stack_link(mat, node, "node_bsdf_sheen", 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 roughness = get_input_value("Roughness", NodeItem::Type::Float);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
NodeItem res = create_node("sheen_bsdf", NodeItem::Type::BSDF);
res.set_input("color", color);
res.set_input("weight", roughness);
res.set_input("roughness", roughness);
if (normal) {
res.set_input("normal", normal);
}
return res;
}
#endif
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_bsdf_sheen_cc } // namespace blender::nodes::node_shader_bsdf_sheen_cc
/* node type definition */ /* node type definition */
@ -62,6 +85,7 @@ void register_node_type_sh_bsdf_sheen()
ntype.initfunc = file_ns::node_shader_init_sheen; ntype.initfunc = file_ns::node_shader_init_sheen;
ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_sheen; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_sheen;
ntype.draw_buttons = file_ns::node_shader_buts_sheen; ntype.draw_buttons = file_ns::node_shader_buts_sheen;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

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); 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);
if (normal) {
res.set_input("normal", normal);
}
return res;
}
#endif
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_bsdf_translucent_cc } // namespace blender::nodes::node_shader_bsdf_translucent_cc
/* node type definition */ /* node type definition */
@ -42,6 +62,7 @@ void register_node_type_sh_bsdf_translucent()
ntype.declare = file_ns::node_declare; ntype.declare = file_ns::node_declare;
ntype.add_ui_poll = object_shader_nodes_poll; ntype.add_ui_poll = object_shader_nodes_poll;
ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_translucent; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_translucent;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }

View File

@ -77,6 +77,33 @@ static void node_shader_update_subsurface_scattering(bNodeTree *ntree, bNode *no
} }
} }
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: IOR and Subsurface Method isn't supported for this node in MaterialX. */
if (to_type_ != NodeItem::Type::BSDF) {
return empty();
}
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
NodeItem radius = get_input_value("Radius", NodeItem::Type::Vector3);
NodeItem anisotropy = get_input_value("Anisotropy", NodeItem::Type::Float);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
NodeItem res = create_node("subsurface_bsdf", NodeItem::Type::BSDF);
res.set_input("weight", val(1.0f));
res.set_input("color", color);
res.set_input("radius", radius * scale);
res.set_input("anisotropy", anisotropy);
if (normal) {
res.set_input("normal", normal);
}
return res;
}
#endif
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_subsurface_scattering_cc } // namespace blender::nodes::node_shader_subsurface_scattering_cc
/* node type definition */ /* node type definition */
@ -95,6 +122,7 @@ void register_node_type_sh_subsurface_scattering()
ntype.initfunc = file_ns::node_shader_init_subsurface_scattering; ntype.initfunc = file_ns::node_shader_init_subsurface_scattering;
ntype.gpu_fn = file_ns::node_shader_gpu_subsurface_scattering; ntype.gpu_fn = file_ns::node_shader_gpu_subsurface_scattering;
ntype.updatefunc = file_ns::node_shader_update_subsurface_scattering; ntype.updatefunc = file_ns::node_shader_update_subsurface_scattering;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }