forked from blender/blender
MaterialX: split standard_surface into basic nodes #26
@ -2,6 +2,8 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
|
|
||||||
#include "node_shader_util.hh"
|
#include "node_shader_util.hh"
|
||||||
@ -287,6 +289,7 @@ static void node_shader_update_principled(bNodeTree *ntree, bNode *node)
|
|||||||
NODE_SHADER_MATERIALX_BEGIN
|
NODE_SHADER_MATERIALX_BEGIN
|
||||||
#ifdef WITH_MATERIALX
|
#ifdef WITH_MATERIALX
|
||||||
{
|
{
|
||||||
|
auto bsdf_inputs = [&]() {
|
||||||
NodeItem base_color = get_input_value("Base Color", NodeItem::Type::Color3);
|
NodeItem base_color = get_input_value("Base Color", NodeItem::Type::Color3);
|
||||||
|
|
||||||
NodeItem subsurface = get_input_value("Subsurface", NodeItem::Type::Float);
|
NodeItem subsurface = get_input_value("Subsurface", NodeItem::Type::Float);
|
||||||
@ -300,7 +303,8 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
/* TODO: use Specular Tint input */
|
/* TODO: use Specular Tint input */
|
||||||
NodeItem anisotropic = get_input_value("Anisotropic", NodeItem::Type::Float);
|
NodeItem anisotropic = get_input_value("Anisotropic", NodeItem::Type::Float);
|
||||||
NodeItem anisotropic_rotation = get_input_value("Anisotropic Rotation", NodeItem::Type::Float);
|
NodeItem anisotropic_rotation = get_input_value("Anisotropic Rotation",
|
||||||
|
NodeItem::Type::Float);
|
||||||
// anisotropic_rotation = 0.5 - (anisotropic_rotation % 1.0)
|
// anisotropic_rotation = 0.5 - (anisotropic_rotation % 1.0)
|
||||||
|
|
||||||
NodeItem sheen = get_input_value("Sheen", NodeItem::Type::Float);
|
NodeItem sheen = get_input_value("Sheen", NodeItem::Type::Float);
|
||||||
@ -313,9 +317,6 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
NodeItem transmission = get_input_value("Transmission", NodeItem::Type::Float);
|
NodeItem transmission = get_input_value("Transmission", NodeItem::Type::Float);
|
||||||
|
|
||||||
NodeItem emission = get_input_value("Emission", NodeItem::Type::Color3);
|
|
||||||
NodeItem emission_strength = get_input_value("Emission Strength", NodeItem::Type::Float);
|
|
||||||
|
|
||||||
NodeItem alpha = get_input_value("Alpha", NodeItem::Type::Float);
|
NodeItem alpha = get_input_value("Alpha", NodeItem::Type::Float);
|
||||||
// transparency = 1.0 - alpha
|
// transparency = 1.0 - alpha
|
||||||
|
|
||||||
@ -325,26 +326,81 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
subsurface_radius = subsurface_radius * subsurface_scale;
|
subsurface_radius = subsurface_radius * subsurface_scale;
|
||||||
|
|
||||||
|
return std::map<std::string, NodeItem> {{"base", val(1.0f)},
|
||||||
|
{"base_color", base_color},
|
||||||
|
{"diffuse_roughness", roughness},
|
||||||
|
{"normal", normal},
|
||||||
|
{"tangent", tangent},
|
||||||
|
{"metalness", metallic},
|
||||||
|
{"specular", specular},
|
||||||
|
{"specular_color", base_color},
|
||||||
|
{"specular_roughness", roughness},
|
||||||
|
{"specular_IOR", ior},
|
||||||
|
{"specular_anisotropy", anisotropic},
|
||||||
|
{"specular_rotation", anisotropic_rotation},
|
||||||
|
{"transmission", transmission},
|
||||||
|
{"transmission_color", base_color},
|
||||||
|
{"transmission_extra_roughness", roughness},
|
||||||
|
{"subsurface", subsurface},
|
||||||
|
{"subsurface_color", base_color},
|
||||||
|
{"subsurface_radius", subsurface_radius},
|
||||||
|
{"subsurface_anisotropy", anisotropic},
|
||||||
|
{"sheen", sheen},
|
||||||
|
{"sheen_color", base_color},
|
||||||
|
{"sheen_roughness", roughness},
|
||||||
|
{"coat", coat},
|
||||||
|
{"coat_color", base_color},
|
||||||
|
{"coat_roughness", coat_roughness},
|
||||||
|
{"coat_IOR", ior},
|
||||||
|
{"coat_anisotropy", anisotropic},
|
||||||
|
{"coat_rotation", anisotropic_rotation},
|
||||||
|
{"coat_normal", coat_normal},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
auto edf_inputs = [&]() {
|
||||||
|
NodeItem emission = get_input_value("Emission", NodeItem::Type::Color3);
|
||||||
|
NodeItem emission_strength = get_input_value("Emission Strength", NodeItem::Type::Float);
|
||||||
|
|
||||||
|
return std::map<std::string, NodeItem>{{"emission", emission_strength},
|
||||||
|
{"emission_color", emission}};
|
||||||
|
};
|
||||||
|
|
||||||
NodeItem res = empty();
|
NodeItem res = empty();
|
||||||
if (to_type_ == NodeItem::Type::BSDF) {
|
if (to_type_ == NodeItem::Type::BSDF) {
|
||||||
|
auto inputs = bsdf_inputs();
|
||||||
|
|
||||||
|
NodeItem roughness = inputs.find("diffuse_roughness")->second;
|
||||||
|
NodeItem anisotropy = inputs.find("specular_anisotropy")->second;
|
||||||
|
NodeItem rotation = inputs.find("specular_rotation")->second;
|
||||||
|
NodeItem base_color = inputs.find("base_color")->second;
|
||||||
|
NodeItem specular = inputs.find("specular")->second;
|
||||||
|
NodeItem coat = inputs.find("coat")->second;
|
||||||
|
NodeItem ior = inputs.find("specular_IOR")->second;
|
||||||
|
NodeItem normal = inputs.find("normal")->second;
|
||||||
|
NodeItem tangent = inputs.find("tangent")->second;
|
||||||
|
|
||||||
NodeItem n_main_tangent = empty();
|
NodeItem n_main_tangent = empty();
|
||||||
if (tangent) {
|
if (tangent) {
|
||||||
NodeItem n_tangent_rotate = create_node("rotate3d", NodeItem::Type::Vector3);
|
NodeItem n_tangent_rotate = create_node("rotate3d", NodeItem::Type::Vector3);
|
||||||
n_tangent_rotate.set_input("in", tangent);
|
n_tangent_rotate.set_input("in", tangent);
|
||||||
n_tangent_rotate.set_input("amount", anisotropic_rotation * val(360.0f));
|
n_tangent_rotate.set_input("amount", rotation * val(360.0f));
|
||||||
n_tangent_rotate.set_input("axis", normal);
|
n_tangent_rotate.set_input("axis", normal);
|
||||||
|
|
||||||
NodeItem n_tangent_rotate_normalize = create_node("normalize", NodeItem::Type::Vector3);
|
NodeItem n_tangent_rotate_normalize = create_node("normalize", NodeItem::Type::Vector3);
|
||||||
n_tangent_rotate_normalize.set_input("in", n_tangent_rotate);
|
n_tangent_rotate_normalize.set_input("in", n_tangent_rotate);
|
||||||
|
|
||||||
n_main_tangent = anisotropic.if_else(
|
n_main_tangent = anisotropy.if_else(
|
||||||
NodeItem::CompareOp::Greater, val(0.0f), n_tangent_rotate_normalize, tangent);
|
NodeItem::CompareOp::Greater,
|
||||||
|
val(0.0f),
|
||||||
|
n_tangent_rotate_normalize,
|
||||||
|
tangent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem n_coat_roughness_vector = create_node("roughness_anisotropy",
|
NodeItem n_coat_roughness_vector = create_node("roughness_anisotropy",
|
||||||
NodeItem::Type::Vector2);
|
NodeItem::Type::Vector2);
|
||||||
n_coat_roughness_vector.set_input("roughness", roughness);
|
n_coat_roughness_vector.set_input("roughness", roughness);
|
||||||
n_coat_roughness_vector.set_input("anisotropy", anisotropic);
|
n_coat_roughness_vector.set_input("anisotropy", anisotropy);
|
||||||
|
|
||||||
NodeItem n_coat_bsdf = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_coat_bsdf = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
||||||
n_coat_bsdf.set_input("weight", coat);
|
n_coat_bsdf.set_input("weight", coat);
|
||||||
@ -352,21 +408,22 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
n_coat_bsdf.set_input("ior", ior);
|
n_coat_bsdf.set_input("ior", ior);
|
||||||
n_coat_bsdf.set_input("scatter_mode", val(std::string("R")));
|
n_coat_bsdf.set_input("scatter_mode", val(std::string("R")));
|
||||||
n_coat_bsdf.set_input("roughness", n_coat_roughness_vector);
|
n_coat_bsdf.set_input("roughness", n_coat_roughness_vector);
|
||||||
if (normal) {
|
|
||||||
n_coat_bsdf.set_input("normal", normal);
|
n_coat_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
|
|
||||||
if (tangent) {
|
if (tangent) {
|
||||||
NodeItem n_coat_tangent_rotate = create_node("rotate3d", NodeItem::Type::Vector3);
|
NodeItem n_coat_tangent_rotate = create_node("rotate3d", NodeItem::Type::Vector3);
|
||||||
n_coat_tangent_rotate.set_input("in", tangent);
|
n_coat_tangent_rotate.set_input("in", tangent);
|
||||||
n_coat_tangent_rotate.set_input("amount", anisotropic_rotation * val(360.0f));
|
n_coat_tangent_rotate.set_input("amount", rotation * val(360.0f));
|
||||||
n_coat_tangent_rotate.set_input("axis", normal);
|
n_coat_tangent_rotate.set_input("axis", normal);
|
||||||
|
|
||||||
NodeItem n_coat_tangent_rotate_normalize = create_node("normalize", NodeItem::Type::Vector3);
|
NodeItem n_coat_tangent_rotate_normalize = create_node("normalize", NodeItem::Type::Vector3);
|
||||||
n_coat_tangent_rotate_normalize.set_input("in", n_coat_tangent_rotate);
|
n_coat_tangent_rotate_normalize.set_input("in", n_coat_tangent_rotate);
|
||||||
|
|
||||||
NodeItem n_coat_tangent = anisotropic.if_else(
|
NodeItem n_coat_tangent = anisotropy.if_else(
|
||||||
NodeItem::CompareOp::Greater, val(0.0f), n_coat_tangent_rotate_normalize, tangent);
|
NodeItem::CompareOp::Greater,
|
||||||
|
val(0.0f),
|
||||||
|
n_coat_tangent_rotate_normalize,
|
||||||
|
tangent);
|
||||||
|
|
||||||
n_coat_bsdf.set_input("tangent", n_coat_tangent);
|
n_coat_bsdf.set_input("tangent", n_coat_tangent);
|
||||||
}
|
}
|
||||||
@ -377,11 +434,13 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
NodeItem n_artistic_ior = create_node("artistic_ior", NodeItem::Type::Multioutput);
|
NodeItem n_artistic_ior = create_node("artistic_ior", NodeItem::Type::Multioutput);
|
||||||
n_artistic_ior.set_input("reflectivity", base_color * val(1.0f));
|
n_artistic_ior.set_input("reflectivity", base_color * val(1.0f));
|
||||||
n_artistic_ior.set_input("edge_color", base_color * specular);
|
n_artistic_ior.set_input(
|
||||||
|
"edge_color", base_color * specular);
|
||||||
NodeItem n_ior_out = n_artistic_ior.add_output("ior", NodeItem::Type::Color3);
|
NodeItem n_ior_out = n_artistic_ior.add_output("ior", NodeItem::Type::Color3);
|
||||||
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) * roughness;
|
NodeItem n_coat_affect_roughness_multiply2 = coat * val(0.0f) *
|
||||||
|
roughness;
|
||||||
NodeItem n_coat_affected_roughness = create_node("mix", NodeItem::Type::Float);
|
NodeItem n_coat_affected_roughness = create_node("mix", NodeItem::Type::Float);
|
||||||
n_coat_affected_roughness.set_input("fg", val(1.0f));
|
n_coat_affected_roughness.set_input("fg", val(1.0f));
|
||||||
n_coat_affected_roughness.set_input("bg", roughness);
|
n_coat_affected_roughness.set_input("bg", roughness);
|
||||||
@ -389,18 +448,14 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
NodeItem n_main_roughness = create_node("roughness_anisotropy", NodeItem::Type::Vector2);
|
NodeItem n_main_roughness = create_node("roughness_anisotropy", NodeItem::Type::Vector2);
|
||||||
n_main_roughness.set_input("roughness", n_coat_affected_roughness);
|
n_main_roughness.set_input("roughness", n_coat_affected_roughness);
|
||||||
n_main_roughness.set_input("anisotropy", anisotropic);
|
n_main_roughness.set_input("anisotropy", anisotropy);
|
||||||
|
|
||||||
NodeItem n_metal_bsdf = create_node("conductor_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_metal_bsdf = create_node("conductor_bsdf", NodeItem::Type::BSDF);
|
||||||
n_metal_bsdf.set_input("ior", n_ior_out);
|
n_metal_bsdf.set_input("ior", n_ior_out);
|
||||||
n_metal_bsdf.set_input("extinction", n_extinction_out);
|
n_metal_bsdf.set_input("extinction", n_extinction_out);
|
||||||
n_metal_bsdf.set_input("roughness", n_main_roughness);
|
n_metal_bsdf.set_input("roughness", n_main_roughness);
|
||||||
if (normal) {
|
|
||||||
n_metal_bsdf.set_input("normal", normal);
|
n_metal_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
if (n_main_tangent) {
|
|
||||||
n_metal_bsdf.set_input("tangent", n_main_tangent);
|
n_metal_bsdf.set_input("tangent", n_main_tangent);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_specular_bsdf = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_specular_bsdf = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
||||||
n_specular_bsdf.set_input("weight", specular);
|
n_specular_bsdf.set_input("weight", specular);
|
||||||
@ -408,50 +463,41 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
n_specular_bsdf.set_input("ior", ior);
|
n_specular_bsdf.set_input("ior", ior);
|
||||||
n_specular_bsdf.set_input("scatter_mode", val(std::string("R")));
|
n_specular_bsdf.set_input("scatter_mode", val(std::string("R")));
|
||||||
n_specular_bsdf.set_input("roughness", n_main_roughness);
|
n_specular_bsdf.set_input("roughness", n_main_roughness);
|
||||||
if (normal) {
|
|
||||||
n_specular_bsdf.set_input("normal", normal);
|
n_specular_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
if (n_main_tangent) {
|
|
||||||
n_specular_bsdf.set_input("tangent", n_main_tangent);
|
n_specular_bsdf.set_input("tangent", n_main_tangent);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_coat_affected_transmission_roughness = create_node("mix", NodeItem::Type::Float);
|
NodeItem n_coat_affected_transmission_roughness = create_node("mix", NodeItem::Type::Float);
|
||||||
n_coat_affected_transmission_roughness.set_input("fg", val(1.0f));
|
n_coat_affected_transmission_roughness.set_input("fg", val(1.0f));
|
||||||
n_coat_affected_transmission_roughness.set_input("bg",
|
n_coat_affected_transmission_roughness.set_input(
|
||||||
(roughness + roughness).clamp(0.0f, 1.0f));
|
"bg",
|
||||||
|
(roughness + roughness)
|
||||||
|
.clamp(0.0f, 1.0f));
|
||||||
n_coat_affected_transmission_roughness.set_input("mix", n_coat_affect_roughness_multiply2);
|
n_coat_affected_transmission_roughness.set_input("mix", n_coat_affect_roughness_multiply2);
|
||||||
|
|
||||||
NodeItem n_transmission_roughness = create_node("roughness_anisotropy",
|
NodeItem n_transmission_roughness = create_node("roughness_anisotropy",
|
||||||
NodeItem::Type::Vector2);
|
NodeItem::Type::Vector2);
|
||||||
n_transmission_roughness.set_input("roughness", n_coat_affected_transmission_roughness);
|
n_transmission_roughness.set_input("roughness", n_coat_affected_transmission_roughness);
|
||||||
n_transmission_roughness.set_input("anisotropy", anisotropic);
|
n_transmission_roughness.set_input("anisotropy", anisotropy);
|
||||||
|
|
||||||
NodeItem n_transmission_bsdf = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_transmission_bsdf = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
||||||
n_transmission_bsdf.set_input("tint", base_color);
|
n_transmission_bsdf.set_input("tint", base_color);
|
||||||
n_transmission_bsdf.set_input("ior", ior);
|
n_transmission_bsdf.set_input("ior", ior);
|
||||||
n_transmission_bsdf.set_input("roughness", n_transmission_roughness);
|
n_transmission_bsdf.set_input("roughness", n_transmission_roughness);
|
||||||
if (normal) {
|
|
||||||
n_transmission_bsdf.set_input("normal", normal);
|
n_transmission_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
if (n_main_tangent) {
|
|
||||||
n_transmission_bsdf.set_input("tangent", n_main_tangent);
|
n_transmission_bsdf.set_input("tangent", n_main_tangent);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_coat_gamma = coat.clamp(0.0f, 1.0f) * val(0.0f) + val(1.0f);
|
NodeItem n_coat_gamma = coat.clamp(0.0f, 1.0f) * val(0.0f) + val(1.0f);
|
||||||
NodeItem n_coat_affected_subsurface_color = base_color.max(val(0.0f)) ^ n_coat_gamma;
|
NodeItem n_coat_affected_subsurface_color = base_color.max(val(0.0f)) ^
|
||||||
|
n_coat_gamma;
|
||||||
NodeItem n_translucent_bsdf = create_node("translucent_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_translucent_bsdf = create_node("translucent_bsdf", NodeItem::Type::BSDF);
|
||||||
n_translucent_bsdf.set_input("color", n_coat_affected_subsurface_color);
|
n_translucent_bsdf.set_input("color", n_coat_affected_subsurface_color);
|
||||||
if (normal) {
|
|
||||||
n_translucent_bsdf.set_input("normal", normal);
|
n_translucent_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_subsurface_bsdf = create_node("subsurface_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_subsurface_bsdf = create_node("subsurface_bsdf", NodeItem::Type::BSDF);
|
||||||
n_subsurface_bsdf.set_input("color", n_coat_affected_subsurface_color);
|
n_subsurface_bsdf.set_input("color", n_coat_affected_subsurface_color);
|
||||||
n_subsurface_bsdf.set_input("radius", subsurface_radius);
|
n_subsurface_bsdf.set_input("radius", inputs.find("subsurface_radius")->second);
|
||||||
n_subsurface_bsdf.set_input("anisotropy", anisotropic);
|
n_subsurface_bsdf.set_input("anisotropy", anisotropy);
|
||||||
if (normal) {
|
|
||||||
n_subsurface_bsdf.set_input("normal", normal);
|
n_subsurface_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_selected_subsurface_bsdf = create_node("mix", NodeItem::Type::BSDF);
|
NodeItem n_selected_subsurface_bsdf = create_node("mix", NodeItem::Type::BSDF);
|
||||||
n_selected_subsurface_bsdf.set_input("fg", n_translucent_bsdf);
|
n_selected_subsurface_bsdf.set_input("fg", n_translucent_bsdf);
|
||||||
@ -459,25 +505,22 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
n_selected_subsurface_bsdf.set_input("mix", val(0.0f));
|
n_selected_subsurface_bsdf.set_input("mix", val(0.0f));
|
||||||
|
|
||||||
NodeItem n_sheen_bsdf = create_node("sheen_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_sheen_bsdf = create_node("sheen_bsdf", NodeItem::Type::BSDF);
|
||||||
n_sheen_bsdf.set_input("weight", sheen);
|
n_sheen_bsdf.set_input("weight", inputs.find("sheen")->second);
|
||||||
n_sheen_bsdf.set_input("color", base_color);
|
n_sheen_bsdf.set_input("color", base_color);
|
||||||
n_sheen_bsdf.set_input("roughness", roughness);
|
n_sheen_bsdf.set_input("roughness", roughness);
|
||||||
if (normal) {
|
|
||||||
n_sheen_bsdf.set_input("normal", normal);
|
n_sheen_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_diffuse_bsdf = create_node("oren_nayar_diffuse_bsdf", NodeItem::Type::BSDF);
|
NodeItem n_diffuse_bsdf = create_node("oren_nayar_diffuse_bsdf", NodeItem::Type::BSDF);
|
||||||
n_diffuse_bsdf.set_input("color", base_color.max(val(0.0f)) ^ n_coat_gamma);
|
n_diffuse_bsdf.set_input("color",
|
||||||
|
base_color.max(val(0.0f)) ^ n_coat_gamma);
|
||||||
n_diffuse_bsdf.set_input("roughness", roughness);
|
n_diffuse_bsdf.set_input("roughness", roughness);
|
||||||
n_diffuse_bsdf.set_input("weight", val(1.0f));
|
n_diffuse_bsdf.set_input("weight", val(1.0f));
|
||||||
if (normal) {
|
|
||||||
n_diffuse_bsdf.set_input("normal", normal);
|
n_diffuse_bsdf.set_input("normal", normal);
|
||||||
}
|
|
||||||
|
|
||||||
NodeItem n_subsurface_mix = create_node("mix", NodeItem::Type::BSDF);
|
NodeItem n_subsurface_mix = create_node("mix", NodeItem::Type::BSDF);
|
||||||
n_subsurface_mix.set_input("fg", n_selected_subsurface_bsdf);
|
n_subsurface_mix.set_input("fg", n_selected_subsurface_bsdf);
|
||||||
n_subsurface_mix.set_input("bg", n_diffuse_bsdf);
|
n_subsurface_mix.set_input("bg", n_diffuse_bsdf);
|
||||||
n_subsurface_mix.set_input("mix", subsurface);
|
n_subsurface_mix.set_input("mix", inputs.find("subsurface")->second);
|
||||||
|
|
||||||
NodeItem n_sheen_layer = create_node("layer", NodeItem::Type::BSDF);
|
NodeItem n_sheen_layer = create_node("layer", NodeItem::Type::BSDF);
|
||||||
n_sheen_layer.set_input("top", n_sheen_bsdf);
|
n_sheen_layer.set_input("top", n_sheen_bsdf);
|
||||||
@ -486,7 +529,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
NodeItem n_transmission_mix = create_node("mix", NodeItem::Type::BSDF);
|
NodeItem n_transmission_mix = create_node("mix", NodeItem::Type::BSDF);
|
||||||
n_transmission_mix.set_input("fg", n_transmission_bsdf);
|
n_transmission_mix.set_input("fg", n_transmission_bsdf);
|
||||||
n_transmission_mix.set_input("bg", n_sheen_layer);
|
n_transmission_mix.set_input("bg", n_sheen_layer);
|
||||||
n_transmission_mix.set_input("mix", transmission);
|
n_transmission_mix.set_input("mix", inputs.find("transmission")->second);
|
||||||
|
|
||||||
NodeItem n_specular_layer = create_node("layer", NodeItem::Type::BSDF);
|
NodeItem n_specular_layer = create_node("layer", NodeItem::Type::BSDF);
|
||||||
n_specular_layer.set_input("top", n_specular_bsdf);
|
n_specular_layer.set_input("top", n_specular_bsdf);
|
||||||
@ -495,7 +538,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
NodeItem n_metalness_mix = create_node("mix", NodeItem::Type::BSDF);
|
NodeItem n_metalness_mix = create_node("mix", NodeItem::Type::BSDF);
|
||||||
n_metalness_mix.set_input("fg", n_metal_bsdf);
|
n_metalness_mix.set_input("fg", n_metal_bsdf);
|
||||||
n_metalness_mix.set_input("bg", n_specular_layer);
|
n_metalness_mix.set_input("bg", n_specular_layer);
|
||||||
n_metalness_mix.set_input("mix", metallic);
|
n_metalness_mix.set_input("mix", inputs.find("metalness")->second);
|
||||||
|
|
||||||
NodeItem n_thin_film_layer = create_node("layer", NodeItem::Type::BSDF);
|
NodeItem n_thin_film_layer = create_node("layer", NodeItem::Type::BSDF);
|
||||||
n_thin_film_layer.set_input("top", n_thin_film_bsdf);
|
n_thin_film_layer.set_input("top", n_thin_film_bsdf);
|
||||||
@ -516,54 +559,61 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
else if (to_type_ == NodeItem::Type::EDF) {
|
else if (to_type_ == NodeItem::Type::EDF) {
|
||||||
|
auto inputs = edf_inputs();
|
||||||
|
|
||||||
res = create_node("uniform_edf", NodeItem::Type::EDF);
|
res = create_node("uniform_edf", NodeItem::Type::EDF);
|
||||||
res.set_input("color", emission * emission_strength);
|
res.set_input("color", inputs.find("emission_color")->second * inputs.find("emission")->second);
|
||||||
}
|
}
|
||||||
else if (to_type_ == NodeItem::Type::SurfaceShader) {
|
else if (to_type_ == NodeItem::Type::SurfaceShader) {
|
||||||
|
auto b_inputs = bsdf_inputs();
|
||||||
|
auto e_inputs = edf_inputs();
|
||||||
|
|
||||||
|
NodeItem roughness = b_inputs.find("diffuse_roughness")->second;
|
||||||
|
NodeItem base_color = b_inputs.find("base_color")->second;
|
||||||
|
NodeItem anisotropic = b_inputs.find("specular_anisotropy")->second;
|
||||||
|
NodeItem ior = b_inputs.find("specular_IOR")->second;
|
||||||
|
NodeItem rotation = b_inputs.find("specular_rotation")->second;
|
||||||
|
|
||||||
res = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
res = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
||||||
res.set_input("base", val(1.0f));
|
res.set_input("base", val(1.0f));
|
||||||
res.set_input("base_color", base_color);
|
res.set_input("base_color", base_color);
|
||||||
res.set_input("diffuse_roughness", roughness);
|
res.set_input("diffuse_roughness", roughness);
|
||||||
if (normal) {
|
|
||||||
res.set_input("normal", normal);
|
|
||||||
}
|
|
||||||
if (tangent) {
|
|
||||||
res.set_input("tangent", tangent);
|
|
||||||
}
|
|
||||||
res.set_input("metalness", metallic);
|
|
||||||
|
|
||||||
res.set_input("specular", specular);
|
res.set_input("metalness", b_inputs.find("metalness")->second );
|
||||||
|
|
||||||
|
res.set_input("specular", b_inputs.find("specular")->second );
|
||||||
res.set_input("specular_color", base_color);
|
res.set_input("specular_color", base_color);
|
||||||
res.set_input("specular_roughness", roughness);
|
res.set_input("specular_roughness", roughness);
|
||||||
res.set_input("specular_IOR", ior);
|
res.set_input("specular_IOR", ior);
|
||||||
res.set_input("specular_anisotropy", anisotropic);
|
res.set_input("specular_anisotropy", anisotropic);
|
||||||
res.set_input("specular_rotation", anisotropic_rotation);
|
res.set_input("specular_rotation", rotation);
|
||||||
|
|
||||||
res.set_input("transmission", transmission);
|
res.set_input("transmission", b_inputs.find("transmission")->second );
|
||||||
res.set_input("transmission_color", base_color);
|
res.set_input("transmission_color", base_color);
|
||||||
res.set_input("transmission_extra_roughness", roughness);
|
res.set_input("transmission_extra_roughness", roughness);
|
||||||
|
|
||||||
res.set_input("subsurface", subsurface);
|
res.set_input("subsurface", b_inputs.find("subsurface")->second );
|
||||||
res.set_input("subsurface_color", base_color);
|
res.set_input("subsurface_color", base_color);
|
||||||
res.set_input("subsurface_radius", subsurface_radius);
|
res.set_input("subsurface_radius", b_inputs.find("subsurface_radius")->second );
|
||||||
res.set_input("subsurface_anisotropy", anisotropic);
|
res.set_input("subsurface_anisotropy", anisotropic);
|
||||||
|
|
||||||
res.set_input("sheen", sheen);
|
res.set_input("sheen", b_inputs.find("sheen")->second );
|
||||||
res.set_input("sheen_color", base_color);
|
res.set_input("sheen_color", base_color);
|
||||||
res.set_input("sheen_roughness", roughness);
|
res.set_input("sheen_roughness", roughness);
|
||||||
|
|
||||||
res.set_input("coat", coat);
|
res.set_input("coat", b_inputs.find("coat")->second );
|
||||||
res.set_input("coat_color", base_color);
|
res.set_input("coat_color", base_color);
|
||||||
res.set_input("coat_roughness", coat_roughness);
|
res.set_input("coat_roughness", b_inputs.find("coat_roughness")->second );
|
||||||
res.set_input("coat_IOR", ior);
|
res.set_input("coat_IOR", ior);
|
||||||
res.set_input("coat_anisotropy", anisotropic);
|
res.set_input("coat_anisotropy", anisotropic);
|
||||||
res.set_input("coat_rotation", anisotropic_rotation);
|
res.set_input("coat_rotation", rotation);
|
||||||
if (coat_normal) {
|
res.set_input("coat_normal", b_inputs.find("coat_normal")->second );
|
||||||
res.set_input("coat_normal", coat_normal);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.set_input("emission", emission_strength);
|
res.set_input("emission", e_inputs.find("emission")->second);
|
||||||
res.set_input("emission_color", emission);
|
res.set_input("emission_color", e_inputs.find("emission_color")->second);
|
||||||
|
|
||||||
|
res.set_input("normal", b_inputs.find("normal")->second);
|
||||||
|
res.set_input("tangent", b_inputs.find("tangent")->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user