Code improvements + Mix node #30

Merged
Bogdan Nagirniak merged 18 commits from BogdanNagirniak/blender:matx-code-improvements into matx-export-material 2023-09-22 18:23:13 +02:00
Showing only changes of commit dae8c96e20 - Show all commits

View File

@ -396,10 +396,12 @@ NODE_SHADER_MATERIALX_BEGIN
NodeItem n_extinction_out = n_artistic_ior.add_output("extinction", NodeItem::Type::Color3); NodeItem n_extinction_out = n_artistic_ior.add_output("extinction", NodeItem::Type::Color3);
NodeItem n_coat_affect_roughness_multiply2 = coat * val(0.0f) * in["coat_roughness"]; NodeItem n_coat_affect_roughness_multiply2 = coat * val(0.0f) * in["coat_roughness"];
NodeItem n_coat_affected_roughness = create_node( NodeItem n_coat_affected_roughness = n_coat_affect_roughness_multiply2.mix(roughness,
"mix", val(1.0f));
NodeItem::Type::Float, // NodeItem n_coat_affected_roughness = create_node(
{{"fg", val(1.0f)}, {"bg", roughness}, {"mix", n_coat_affect_roughness_multiply2}}); // "mix",
// NodeItem::Type::Float,
// {{"fg", val(1.0f)}, {"bg", roughness}, {"mix", n_coat_affect_roughness_multiply2}});
NodeItem n_main_roughness = create_node( NodeItem n_main_roughness = create_node(
"roughness_anisotropy", "roughness_anisotropy",
@ -424,12 +426,14 @@ NODE_SHADER_MATERIALX_BEGIN
{"normal", normal}, {"normal", normal},
{"tangent", n_main_tangent}}); {"tangent", n_main_tangent}});
NodeItem n_coat_affected_transmission_roughness = create_node( NodeItem n_coat_affected_transmission_roughness = n_coat_affect_roughness_multiply2.mix(
"mix", (roughness + roughness).clamp(), val(1.0f));
NodeItem::Type::Float, // NodeItem n_coat_affected_transmission_roughness = create_node(
{{"fg", val(1.0f)}, // "mix",
{"bg", (roughness + roughness).clamp(0.0f, 1.0f)}, // NodeItem::Type::Float,
{"mix", n_coat_affect_roughness_multiply2}}); // {{"fg", val(1.0f)},
// {"bg", (roughness + roughness).clamp(0.0f, 1.0f)},
// {"mix", n_coat_affect_roughness_multiply2}});
NodeItem n_transmission_roughness = create_node( NodeItem n_transmission_roughness = create_node(
"roughness_anisotropy", "roughness_anisotropy",
@ -459,10 +463,11 @@ NODE_SHADER_MATERIALX_BEGIN
{"anisotropy", in["subsurface_anisotropy"]}, {"anisotropy", in["subsurface_anisotropy"]},
{"normal", normal}}); {"normal", normal}});
NodeItem n_selected_subsurface_bsdf = create_node( NodeItem n_selected_subsurface_bsdf = n_subsurface_bsdf;
"mix", // NodeItem n_selected_subsurface_bsdf = create_node(
NodeItem::Type::BSDF, // "mix",
{{"fg", n_translucent_bsdf}, {"bg", n_subsurface_bsdf}, {"mix", val(0.0f)}}); // NodeItem::Type::BSDF,
// {{"fg", n_translucent_bsdf}, {"bg", n_subsurface_bsdf}, {"mix", val(0.0f)}});
NodeItem n_sheen_bsdf = create_node("sheen_bsdf", NodeItem n_sheen_bsdf = create_node("sheen_bsdf",
NodeItem::Type::BSDF, NodeItem::Type::BSDF,
@ -478,26 +483,29 @@ NODE_SHADER_MATERIALX_BEGIN
{"weight", val(1.0f)}, {"weight", val(1.0f)},
{"normal", normal}}); {"normal", normal}});
NodeItem n_subsurface_mix = create_node( NodeItem n_subsurface_mix = in["subsurface"].mix(n_diffuse_bsdf, n_selected_subsurface_bsdf);
"mix", // NodeItem n_subsurface_mix = create_node(
NodeItem::Type::BSDF, // "mix",
{{"fg", n_selected_subsurface_bsdf}, {"bg", n_diffuse_bsdf}, {"mix", in["subsurface"]}}); // NodeItem::Type::BSDF,
// {{"fg", n_selected_subsurface_bsdf}, {"bg", n_diffuse_bsdf}, {"mix", in["subsurface"]}});
NodeItem n_sheen_layer = create_node( NodeItem n_sheen_layer = create_node(
"layer", NodeItem::Type::BSDF, {{"top", n_sheen_bsdf}, {"base", n_subsurface_mix}}); "layer", NodeItem::Type::BSDF, {{"top", n_sheen_bsdf}, {"base", n_subsurface_mix}});
NodeItem n_transmission_mix = create_node( NodeItem n_transmission_mix = in["transmission"].mix(n_sheen_layer, n_transmission_bsdf);
"mix", // NodeItem n_transmission_mix = create_node(
NodeItem::Type::BSDF, // "mix",
{{"fg", n_transmission_bsdf}, {"bg", n_sheen_layer}, {"mix", in["transmission"]}}); // NodeItem::Type::BSDF,
// {{"fg", n_transmission_bsdf}, {"bg", n_sheen_layer}, {"mix", in["transmission"]}});
NodeItem n_specular_layer = create_node( NodeItem n_specular_layer = create_node(
"layer", NodeItem::Type::BSDF, {{"top", n_specular_bsdf}, {"base", n_transmission_mix}}); "layer", NodeItem::Type::BSDF, {{"top", n_specular_bsdf}, {"base", n_transmission_mix}});
NodeItem n_metalness_mix = create_node( NodeItem n_metalness_mix = in["metallic"].mix(n_specular_layer, n_metal_bsdf);
"mix", // NodeItem n_metalness_mix = create_node(
NodeItem::Type::BSDF, // "mix",
{{"fg", n_metal_bsdf}, {"bg", n_specular_layer}, {"mix", in["metallic"]}}); // NodeItem::Type::BSDF,
// {{"fg", n_metal_bsdf}, {"bg", n_specular_layer}, {"mix", in["metallic"]}});
NodeItem n_thin_film_layer = create_node( NodeItem n_thin_film_layer = create_node(
"layer", NodeItem::Type::BSDF, {{"top", n_thin_film_bsdf}, {"base", n_metalness_mix}}); "layer", NodeItem::Type::BSDF, {{"top", n_thin_film_bsdf}, {"base", n_metalness_mix}});
@ -505,11 +513,13 @@ NODE_SHADER_MATERIALX_BEGIN
NodeItem n_opacity_luminance = create_node( NodeItem n_opacity_luminance = create_node(
"luminance", NodeItem::Type::Color3, {{"in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))}}); "luminance", NodeItem::Type::Color3, {{"in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))}});
NodeItem n_coat_attenuation = create_node("mix", NodeItem n_coat_attenuation = coat.mix(val(MaterialX::Color3(1.0f, 1.0f, 1.0f)),
NodeItem::Type::Color3, in["coat_tint"]);
{{"fg", in["coat_tint"]}, // NodeItem n_coat_attenuation = create_node("mix",
{"bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))}, // NodeItem::Type::Color3,
{"mix", coat}}); // {{"fg", in["coat_tint"]},
// {"bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))},
// {"mix", coat}});
res = create_node("layer", res = create_node("layer",
NodeItem::Type::BSDF, NodeItem::Type::BSDF,