1
1
Fork 0

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
1 changed files with 41 additions and 31 deletions
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_coat_affect_roughness_multiply2 = coat * val(0.0f) * in["coat_roughness"];
NodeItem n_coat_affected_roughness = create_node(
"mix",
NodeItem::Type::Float,
{{"fg", val(1.0f)}, {"bg", roughness}, {"mix", n_coat_affect_roughness_multiply2}});
NodeItem n_coat_affected_roughness = n_coat_affect_roughness_multiply2.mix(roughness,
val(1.0f));
// NodeItem n_coat_affected_roughness = create_node(
// "mix",
// NodeItem::Type::Float,
// {{"fg", val(1.0f)}, {"bg", roughness}, {"mix", n_coat_affect_roughness_multiply2}});
NodeItem n_main_roughness = create_node(
"roughness_anisotropy",
@ -424,12 +426,14 @@ NODE_SHADER_MATERIALX_BEGIN
{"normal", normal},
{"tangent", n_main_tangent}});
NodeItem n_coat_affected_transmission_roughness = create_node(
"mix",
NodeItem::Type::Float,
{{"fg", val(1.0f)},
{"bg", (roughness + roughness).clamp(0.0f, 1.0f)},
{"mix", n_coat_affect_roughness_multiply2}});
NodeItem n_coat_affected_transmission_roughness = n_coat_affect_roughness_multiply2.mix(
(roughness + roughness).clamp(), val(1.0f));
// NodeItem n_coat_affected_transmission_roughness = create_node(
// "mix",
// NodeItem::Type::Float,
// {{"fg", val(1.0f)},
// {"bg", (roughness + roughness).clamp(0.0f, 1.0f)},
// {"mix", n_coat_affect_roughness_multiply2}});
NodeItem n_transmission_roughness = create_node(
"roughness_anisotropy",
@ -459,10 +463,11 @@ NODE_SHADER_MATERIALX_BEGIN
{"anisotropy", in["subsurface_anisotropy"]},
{"normal", normal}});
NodeItem n_selected_subsurface_bsdf = create_node(
"mix",
NodeItem::Type::BSDF,
{{"fg", n_translucent_bsdf}, {"bg", n_subsurface_bsdf}, {"mix", val(0.0f)}});
NodeItem n_selected_subsurface_bsdf = n_subsurface_bsdf;
// NodeItem n_selected_subsurface_bsdf = create_node(
// "mix",
// NodeItem::Type::BSDF,
// {{"fg", n_translucent_bsdf}, {"bg", n_subsurface_bsdf}, {"mix", val(0.0f)}});
NodeItem n_sheen_bsdf = create_node("sheen_bsdf",
NodeItem::Type::BSDF,
@ -478,26 +483,29 @@ NODE_SHADER_MATERIALX_BEGIN
{"weight", val(1.0f)},
{"normal", normal}});
NodeItem n_subsurface_mix = create_node(
"mix",
NodeItem::Type::BSDF,
{{"fg", n_selected_subsurface_bsdf}, {"bg", n_diffuse_bsdf}, {"mix", in["subsurface"]}});
NodeItem n_subsurface_mix = in["subsurface"].mix(n_diffuse_bsdf, n_selected_subsurface_bsdf);
// NodeItem n_subsurface_mix = create_node(
// "mix",
// NodeItem::Type::BSDF,
// {{"fg", n_selected_subsurface_bsdf}, {"bg", n_diffuse_bsdf}, {"mix", in["subsurface"]}});
NodeItem n_sheen_layer = create_node(
"layer", NodeItem::Type::BSDF, {{"top", n_sheen_bsdf}, {"base", n_subsurface_mix}});
NodeItem n_transmission_mix = create_node(
"mix",
NodeItem::Type::BSDF,
{{"fg", n_transmission_bsdf}, {"bg", n_sheen_layer}, {"mix", in["transmission"]}});
NodeItem n_transmission_mix = in["transmission"].mix(n_sheen_layer, n_transmission_bsdf);
// NodeItem n_transmission_mix = create_node(
// "mix",
// NodeItem::Type::BSDF,
// {{"fg", n_transmission_bsdf}, {"bg", n_sheen_layer}, {"mix", in["transmission"]}});
NodeItem n_specular_layer = create_node(
"layer", NodeItem::Type::BSDF, {{"top", n_specular_bsdf}, {"base", n_transmission_mix}});
NodeItem n_metalness_mix = create_node(
"mix",
NodeItem::Type::BSDF,
{{"fg", n_metal_bsdf}, {"bg", n_specular_layer}, {"mix", in["metallic"]}});
NodeItem n_metalness_mix = in["metallic"].mix(n_specular_layer, n_metal_bsdf);
// NodeItem n_metalness_mix = create_node(
// "mix",
// NodeItem::Type::BSDF,
// {{"fg", n_metal_bsdf}, {"bg", n_specular_layer}, {"mix", in["metallic"]}});
NodeItem n_thin_film_layer = create_node(
"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(
"luminance", NodeItem::Type::Color3, {{"in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))}});
NodeItem n_coat_attenuation = create_node("mix",
NodeItem::Type::Color3,
{{"fg", in["coat_tint"]},
{"bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))},
{"mix", coat}});
NodeItem n_coat_attenuation = coat.mix(val(MaterialX::Color3(1.0f, 1.0f, 1.0f)),
in["coat_tint"]);
// NodeItem n_coat_attenuation = create_node("mix",
// NodeItem::Type::Color3,
// {{"fg", in["coat_tint"]},
// {"bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))},
// {"mix", coat}});
res = create_node("layer",
NodeItem::Type::BSDF,