forked from blender/blender
MaterialX: split standard_surface into basic nodes #26
@ -382,13 +382,10 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
NodeItem n_main_tangent = empty();
|
NodeItem n_main_tangent = empty();
|
||||||
if (tangent) {
|
if (tangent) {
|
||||||
NodeItem n_tangent_rotate = create_node("rotate3d",
|
NodeItem n_tangent_rotate = create_node(
|
||||||
|
"rotate3d",
|
||||||
NodeItem::Type::Vector3,
|
NodeItem::Type::Vector3,
|
||||||
{
|
{{"in", tangent}, {"amount", rotation * val(360.0f)}, {"axis", normal}});
|
||||||
{"in", tangent},
|
|
||||||
{"amount", rotation * val(360.0f)},
|
|
||||||
{"axis", normal},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_tangent_rotate_normalize = create_node(
|
NodeItem n_tangent_rotate_normalize = create_node(
|
||||||
"normalize", NodeItem::Type::Vector3, {{"in", n_tangent_rotate}});
|
"normalize", NodeItem::Type::Vector3, {{"in", n_tangent_rotate}});
|
||||||
@ -397,38 +394,28 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
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,
|
||||||
{
|
{{"roughness", roughness}, {"anisotropy", anisotropy}});
|
||||||
{"roughness", roughness},
|
|
||||||
{"anisotropy", anisotropy},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_coat_bsdf = create_node("dielectric_bsdf",
|
NodeItem n_coat_bsdf = create_node("dielectric_bsdf",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"weight", coat},
|
||||||
{"weight", coat},
|
|
||||||
{"tint", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))},
|
{"tint", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))},
|
||||||
{"ior", ior},
|
{"ior", ior},
|
||||||
{"scatter_mode", val(std::string("R"))},
|
{"scatter_mode", val(std::string("R"))},
|
||||||
{"roughness", n_coat_roughness_vector},
|
{"roughness", n_coat_roughness_vector},
|
||||||
{"normal", normal},
|
{"normal", normal}});
|
||||||
});
|
|
||||||
|
|
||||||
if (tangent) {
|
if (tangent) {
|
||||||
NodeItem n_coat_tangent_rotate = create_node("rotate3d",
|
NodeItem n_coat_tangent_rotate = create_node(
|
||||||
|
"rotate3d",
|
||||||
NodeItem::Type::Vector3,
|
NodeItem::Type::Vector3,
|
||||||
{
|
{{"in", tangent}, {"amount", rotation * val(360.0f)}, {"axis", normal}});
|
||||||
{"in", tangent},
|
|
||||||
{"amount", rotation * val(360.0f)},
|
|
||||||
{"axis", normal},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_coat_tangent_rotate_normalize = create_node("normalize",
|
NodeItem n_coat_tangent_rotate_normalize = create_node(
|
||||||
NodeItem::Type::Vector3,
|
"normalize", NodeItem::Type::Vector3, {{"in", n_coat_tangent_rotate}});
|
||||||
{
|
|
||||||
{"in", n_coat_tangent_rotate},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_coat_tangent = anisotropy.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);
|
||||||
@ -436,19 +423,13 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
n_coat_bsdf.set_input("tangent", n_coat_tangent);
|
n_coat_bsdf.set_input("tangent", n_coat_tangent);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem n_thin_film_bsdf = create_node("thin_film_bsdf",
|
NodeItem n_thin_film_bsdf = create_node(
|
||||||
NodeItem::Type::BSDF,
|
"thin_film_bsdf", NodeItem::Type::BSDF, {{"thickness", val(0.0f)}, {"ior", val(1.5f)}});
|
||||||
{
|
|
||||||
{"thickness", val(0.0f)},
|
|
||||||
{"ior", val(1.5f)},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_artistic_ior = create_node("artistic_ior",
|
NodeItem n_artistic_ior = create_node(
|
||||||
|
"artistic_ior",
|
||||||
NodeItem::Type::Multioutput,
|
NodeItem::Type::Multioutput,
|
||||||
{
|
{{"reflectivity", base_color * val(1.0f)}, {"edge_color", base_color * specular}});
|
||||||
{"reflectivity", base_color * val(1.0f)},
|
|
||||||
{"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);
|
||||||
@ -457,40 +438,30 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
NodeItem n_coat_affected_roughness = create_node(
|
NodeItem n_coat_affected_roughness = create_node(
|
||||||
"mix",
|
"mix",
|
||||||
NodeItem::Type::Float,
|
NodeItem::Type::Float,
|
||||||
{
|
{{"fg", val(1.0f)}, {"bg", roughness}, {"mix", n_coat_affect_roughness_multiply2}});
|
||||||
{"fg", val(1.0f)},
|
|
||||||
{"bg", roughness},
|
|
||||||
{"mix", n_coat_affect_roughness_multiply2},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_main_roughness = create_node("roughness_anisotropy",
|
NodeItem n_main_roughness = create_node(
|
||||||
|
"roughness_anisotropy",
|
||||||
NodeItem::Type::Vector2,
|
NodeItem::Type::Vector2,
|
||||||
{
|
{{"roughness", n_coat_affected_roughness}, {"anisotropy", anisotropy}});
|
||||||
{"roughness", n_coat_affected_roughness},
|
|
||||||
{"anisotropy", anisotropy},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_metal_bsdf = create_node("conductor_bsdf",
|
NodeItem n_metal_bsdf = create_node("conductor_bsdf",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"ior", n_ior_out},
|
||||||
{"ior", n_ior_out},
|
|
||||||
{"extinction", n_extinction_out},
|
{"extinction", n_extinction_out},
|
||||||
{"roughness", n_main_roughness},
|
{"roughness", n_main_roughness},
|
||||||
{"normal", normal},
|
{"normal", normal},
|
||||||
{"tangent", n_main_tangent},
|
{"tangent", n_main_tangent}});
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_specular_bsdf = create_node("dielectric_bsdf",
|
NodeItem n_specular_bsdf = create_node("dielectric_bsdf",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"weight", specular},
|
||||||
{"weight", specular},
|
|
||||||
{"tint", base_color},
|
{"tint", base_color},
|
||||||
{"ior", ior},
|
{"ior", ior},
|
||||||
{"scatter_mode", val(std::string("R"))},
|
{"scatter_mode", val(std::string("R"))},
|
||||||
{"roughness", n_main_roughness},
|
{"roughness", n_main_roughness},
|
||||||
{"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 = create_node(
|
||||||
"mix",
|
"mix",
|
||||||
@ -504,128 +475,87 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
NodeItem n_transmission_roughness = create_node(
|
NodeItem n_transmission_roughness = create_node(
|
||||||
"roughness_anisotropy",
|
"roughness_anisotropy",
|
||||||
NodeItem::Type::Vector2,
|
NodeItem::Type::Vector2,
|
||||||
{
|
{{"roughness", n_coat_affected_transmission_roughness}, {"anisotropy", anisotropy}});
|
||||||
{"roughness", n_coat_affected_transmission_roughness},
|
|
||||||
{"anisotropy", anisotropy},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_transmission_bsdf = create_node("dielectric_bsdf",
|
NodeItem n_transmission_bsdf = create_node("dielectric_bsdf",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"tint", base_color},
|
||||||
{"tint", base_color},
|
|
||||||
{"ior", ior},
|
{"ior", ior},
|
||||||
{"roughness", n_transmission_roughness},
|
{"roughness", n_transmission_roughness},
|
||||||
{"normal", normal},
|
{"normal", normal},
|
||||||
{"tangent", n_main_tangent},
|
{"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 n_translucent_bsdf = create_node(
|
||||||
|
"translucent_bsdf",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"color", n_coat_affected_subsurface_color}, {"normal", normal}});
|
||||||
{"color", n_coat_affected_subsurface_color},
|
|
||||||
{"normal", normal},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_subsurface_bsdf = create_node(
|
NodeItem n_subsurface_bsdf = create_node("subsurface_bsdf",
|
||||||
"subsurface_bsdf",
|
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"color", n_coat_affected_subsurface_color},
|
||||||
{"color", n_coat_affected_subsurface_color},
|
|
||||||
{"radius", inputs.find("subsurface_radius")->second},
|
{"radius", inputs.find("subsurface_radius")->second},
|
||||||
{"anisotropy", anisotropy},
|
{"anisotropy", anisotropy},
|
||||||
{"normal", normal},
|
{"normal", normal}});
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_selected_subsurface_bsdf = create_node("mix",
|
NodeItem n_selected_subsurface_bsdf = create_node(
|
||||||
|
"mix",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"fg", n_translucent_bsdf}, {"bg", n_subsurface_bsdf}, {"mix", val(0.0f)}});
|
||||||
{"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,
|
||||||
{
|
{{"weight", inputs.find("sheen")->second},
|
||||||
{"weight", inputs.find("sheen")->second},
|
|
||||||
{"color", base_color},
|
{"color", base_color},
|
||||||
{"roughness", roughness},
|
{"roughness", roughness},
|
||||||
{"normal", normal},
|
{"normal", normal}});
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_diffuse_bsdf = create_node("oren_nayar_diffuse_bsdf",
|
NodeItem n_diffuse_bsdf = create_node("oren_nayar_diffuse_bsdf",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"color", base_color.max(val(0.0f)) ^ n_coat_gamma},
|
||||||
{"color", base_color.max(val(0.0f)) ^ n_coat_gamma},
|
|
||||||
{"roughness", roughness},
|
{"roughness", roughness},
|
||||||
{"weight", val(1.0f)},
|
{"weight", val(1.0f)},
|
||||||
{"normal", normal},
|
{"normal", normal}});
|
||||||
});
|
|
||||||
|
|
||||||
DagerD marked this conversation as resolved
Outdated
|
|||||||
NodeItem n_subsurface_mix = create_node("mix",
|
NodeItem n_subsurface_mix = create_node("mix",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"fg", n_selected_subsurface_bsdf},
|
||||||
{"fg", n_selected_subsurface_bsdf},
|
|
||||||
{"bg", n_diffuse_bsdf},
|
{"bg", n_diffuse_bsdf},
|
||||||
{"mix", inputs.find("subsurface")->second},
|
{"mix", inputs.find("subsurface")->second}});
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_sheen_layer = create_node("layer",
|
NodeItem n_sheen_layer = create_node(
|
||||||
NodeItem::Type::BSDF,
|
"layer", NodeItem::Type::BSDF, {{"top", n_sheen_bsdf}, {"base", n_subsurface_mix}});
|
||||||
{
|
|
||||||
{"top", n_sheen_bsdf},
|
|
||||||
{"base", n_subsurface_mix},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_transmission_mix = create_node("mix",
|
NodeItem n_transmission_mix = create_node("mix",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"fg", n_transmission_bsdf},
|
||||||
{"fg", n_transmission_bsdf},
|
|
||||||
{"bg", n_sheen_layer},
|
{"bg", n_sheen_layer},
|
||||||
{"mix", inputs.find("transmission")->second},
|
{"mix", inputs.find("transmission")->second}});
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_specular_layer = create_node("layer",
|
NodeItem n_specular_layer = create_node(
|
||||||
NodeItem::Type::BSDF,
|
"layer", NodeItem::Type::BSDF, {{"top", n_specular_bsdf}, {"base", n_transmission_mix}});
|
||||||
{
|
|
||||||
{"top", n_specular_bsdf},
|
|
||||||
{"base", n_transmission_mix},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_metalness_mix = create_node("mix",
|
NodeItem n_metalness_mix = create_node("mix",
|
||||||
NodeItem::Type::BSDF,
|
NodeItem::Type::BSDF,
|
||||||
{
|
{{"fg", n_metal_bsdf},
|
||||||
{"fg", n_metal_bsdf},
|
|
||||||
{"bg", n_specular_layer},
|
{"bg", n_specular_layer},
|
||||||
{"mix", inputs.find("metalness")->second},
|
{"mix", inputs.find("metalness")->second}});
|
||||||
});
|
|
||||||
|
|
||||||
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}});
|
||||||
|
|
||||||
NodeItem n_opacity_luminance = create_node(
|
NodeItem n_opacity_luminance = create_node(
|
||||||
"luminance",
|
"luminance", NodeItem::Type::Color3, {{"in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))}});
|
||||||
NodeItem::Type::Color3,
|
|
||||||
{
|
|
||||||
{"in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))},
|
|
||||||
});
|
|
||||||
|
|
||||||
NodeItem n_coat_attenuation = create_node("mix",
|
NodeItem n_coat_attenuation = create_node(
|
||||||
|
"mix",
|
||||||
NodeItem::Type::Color3,
|
NodeItem::Type::Color3,
|
||||||
{
|
{{"fg", base_color}, {"bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f))}, {"mix", coat}});
|
||||||
{"fg", base_color},
|
|
||||||
{"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,
|
||||||
{
|
{{"top", n_coat_bsdf}, {"base", n_thin_film_layer * n_coat_attenuation}});
|
||||||
{"top", n_coat_bsdf},
|
|
||||||
{"base", n_thin_film_layer * n_coat_attenuation},
|
|
||||||
});
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -635,9 +565,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
res = create_node(
|
res = create_node(
|
||||||
"uniform_edf",
|
"uniform_edf",
|
||||||
NodeItem::Type::EDF,
|
NodeItem::Type::EDF,
|
||||||
{
|
{{"color", inputs.find("emission_color")->second * inputs.find("emission")->second}});
|
||||||
{"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 b_inputs = bsdf_inputs();
|
||||||
@ -651,8 +579,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
res = create_node("standard_surface",
|
res = create_node("standard_surface",
|
||||||
NodeItem::Type::SurfaceShader,
|
NodeItem::Type::SurfaceShader,
|
||||||
{
|
{{"base", val(1.0f)},
|
||||||
{"base", val(1.0f)},
|
|
||||||
{"base_color", base_color},
|
{"base_color", base_color},
|
||||||
{"diffuse_roughness", roughness},
|
{"diffuse_roughness", roughness},
|
||||||
{"metalness", b_inputs.find("metalness")->second},
|
{"metalness", b_inputs.find("metalness")->second},
|
||||||
@ -682,8 +609,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
{"emission", e_inputs.find("emission")->second},
|
{"emission", e_inputs.find("emission")->second},
|
||||||
{"emission_color", e_inputs.find("emission_color")->second},
|
{"emission_color", e_inputs.find("emission_color")->second},
|
||||||
{"normal", b_inputs.find("normal")->second},
|
{"normal", b_inputs.find("normal")->second},
|
||||||
{"tangent", b_inputs.find("tangent")->second},
|
{"tangent", b_inputs.find("tangent")->second}});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
Reference in New Issue
Block a user
This node is created in MaterialOutput.
Should be: