MaterialX: Implement more shader nodes #23

Merged
Bogdan Nagirniak merged 4 commits from matx-add-other-shader-nodes into matx-export-material 2023-09-15 20:11:01 +02:00
Showing only changes of commit 1979715b31 - Show all commits

View File

@ -45,30 +45,42 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
if (to_type_ != NodeItem::Type::SurfaceShader) {
/* TODO: implement for BSDF and EDF */
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 roughness = get_input_value("Roughness", NodeItem::Type::Vector2);
NodeItem ior = get_input_value("IOR", NodeItem::Type::Float);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
NodeItem res = create_node("standard_surface", NodeItem::Type::SurfaceShader);
res.set_input("base", val(1.0f));
NodeItem dielectric = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
if (normal) {
res.set_input("normal", normal);
dielectric.set_input("normal", normal);
}
res.set_input("base_color", color);
res.set_input("diffuse_roughness", roughness);
res.set_input("specular", val(0.5f));
res.set_input("specular_color", color);
res.set_input("specular_roughness", roughness);
res.set_input("specular_IOR", ior);
res.set_input("transmission", val(1.0f));
res.set_input("transmission_color", color);
res.set_input("transmission_depth", val(10.0f));
dielectric.set_input("tint", color);
dielectric.set_input("roughness", roughness);
dielectric.set_input("ior", ior);
dielectric.set_input("scatter_mode", val(std::string("RT")));
NodeItem artistic_ior = create_node("artistic_ior", NodeItem::Type::Multioutput);
artistic_ior.add_output("ior", NodeItem::Type::Color3);
artistic_ior.add_output("extinction", NodeItem::Type::Color3);
artistic_ior.set_input("reflectivity", color);
artistic_ior.set_input("edge_color", color);
NodeItem conductor = create_node("conductor_bsdf", NodeItem::Type::BSDF);
if (normal) {
conductor.set_input("normal", normal);
}
conductor.set_input_output("ior", artistic_ior, "ior");
conductor.set_input_output("extinction", artistic_ior, "extinction");
conductor.set_input("roughness", roughness);
NodeItem res = create_node("mix", NodeItem::Type::BSDF);
Review

Dielectric already has Reflection and Transmission channels (dielectric -> scatter_mode = "RT"). Do we need one more mix with the Reflection channel (conductor)?

Dielectric already has Reflection and Transmission channels (dielectric -> scatter_mode = "RT"). Do we need one more mix with the Reflection channel (conductor)?
res.set_input("fg", dielectric);
res.set_input("bg", conductor);
res.set_input("mix", val(0.5f));
return res ;
}