forked from blender/blender
MaterialX: split standard_surface into basic nodes #26
@ -287,11 +287,6 @@ static void node_shader_update_principled(bNodeTree *ntree, bNode *node)
|
|||||||
NODE_SHADER_MATERIALX_BEGIN
|
NODE_SHADER_MATERIALX_BEGIN
|
||||||
#ifdef WITH_MATERIALX
|
#ifdef WITH_MATERIALX
|
||||||
{
|
{
|
||||||
if (to_type_ != NodeItem::Type::SurfaceShader) {
|
|
||||||
/* TODO: implement for BSDF and EDF */
|
|
||||||
return empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
@ -330,6 +325,8 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
|
|
||||||
subsurface_radius = subsurface_radius * subsurface_scale;
|
subsurface_radius = subsurface_radius * subsurface_scale;
|
||||||
|
|
||||||
|
NodeItem res = empty();
|
||||||
|
if (to_type_ == NodeItem::Type::BSDF) {
|
||||||
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);
|
||||||
@ -344,7 +341,8 @@ 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::Type::Vector2);
|
NodeItem n_coat_roughness_vector = create_node("roughness_anisotropy",
|
||||||
|
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", anisotropic);
|
||||||
|
|
||||||
@ -423,7 +421,8 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
(roughness + roughness).clamp(0.0f, 1.0f));
|
(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::Type::Vector2);
|
NodeItem n_transmission_roughness = create_node("roughness_anisotropy",
|
||||||
|
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", anisotropic);
|
||||||
|
|
||||||
@ -505,22 +504,67 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
NodeItem n_opacity_luminance = create_node("luminance", NodeItem::Type::Color3);
|
NodeItem n_opacity_luminance = create_node("luminance", NodeItem::Type::Color3);
|
||||||
n_opacity_luminance.set_input("in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f)));
|
n_opacity_luminance.set_input("in", val(MaterialX::Color3(1.0f, 1.0f, 1.0f)));
|
||||||
|
|
||||||
NodeItem n_emission_edf = create_node("uniform_edf", NodeItem::Type::EDF);
|
|
||||||
n_emission_edf.set_input("color", emission * emission_strength);
|
|
||||||
|
|
||||||
NodeItem n_coat_attenuation = create_node("mix", NodeItem::Type::Color3);
|
NodeItem n_coat_attenuation = create_node("mix", NodeItem::Type::Color3);
|
||||||
n_coat_attenuation.set_input("fg", base_color);
|
n_coat_attenuation.set_input("fg", base_color);
|
||||||
n_coat_attenuation.set_input("bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f)));
|
n_coat_attenuation.set_input("bg", val(MaterialX::Color3(1.0f, 1.0f, 1.0f)));
|
||||||
n_coat_attenuation.set_input("mix", coat);
|
n_coat_attenuation.set_input("mix", coat);
|
||||||
|
|
||||||
NodeItem n_coat_layer = create_node("layer", NodeItem::Type::BSDF);
|
res = create_node("layer", NodeItem::Type::BSDF);
|
||||||
n_coat_layer.set_input("top", n_coat_bsdf);
|
res.set_input("top", n_coat_bsdf);
|
||||||
n_coat_layer.set_input("base", n_thin_film_layer * n_coat_attenuation);
|
res.set_input("base", n_thin_film_layer * n_coat_attenuation);
|
||||||
|
|
||||||
NodeItem res = create_node("surface", NodeItem::Type::SurfaceShader);
|
return res;
|
||||||
res.set_input("bsdf", n_coat_layer);
|
}
|
||||||
res.set_input("edf", n_emission_edf);
|
else if (to_type_ == NodeItem::Type::EDF) {
|
||||||
res.set_input("opacity", n_opacity_luminance.extract(0));
|
res = create_node("uniform_edf", NodeItem::Type::EDF);
|
||||||
|
res.set_input("color", emission * emission_strength);
|
||||||
|
}
|
||||||
|
else if (to_type_ == NodeItem::Type::SurfaceShader) {
|
||||||
|
res = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
||||||
|
res.set_input("base", val(1.0f));
|
||||||
|
res.set_input("base_color", base_color);
|
||||||
|
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("specular_color", base_color);
|
||||||
|
res.set_input("specular_roughness", roughness);
|
||||||
|
res.set_input("specular_IOR", ior);
|
||||||
|
res.set_input("specular_anisotropy", anisotropic);
|
||||||
|
res.set_input("specular_rotation", anisotropic_rotation);
|
||||||
|
|
||||||
|
res.set_input("transmission", transmission);
|
||||||
|
res.set_input("transmission_color", base_color);
|
||||||
|
res.set_input("transmission_extra_roughness", roughness);
|
||||||
|
|
||||||
|
res.set_input("subsurface", subsurface);
|
||||||
|
res.set_input("subsurface_color", base_color);
|
||||||
|
res.set_input("subsurface_radius", subsurface_radius);
|
||||||
|
res.set_input("subsurface_anisotropy", anisotropic);
|
||||||
|
|
||||||
|
res.set_input("sheen", sheen);
|
||||||
|
res.set_input("sheen_color", base_color);
|
||||||
|
res.set_input("sheen_roughness", roughness);
|
||||||
|
|
||||||
|
res.set_input("coat", coat);
|
||||||
|
res.set_input("coat_color", base_color);
|
||||||
|
res.set_input("coat_roughness", coat_roughness);
|
||||||
|
res.set_input("coat_IOR", ior);
|
||||||
|
res.set_input("coat_anisotropy", anisotropic);
|
||||||
|
res.set_input("coat_rotation", anisotropic_rotation);
|
||||||
|
if (coat_normal) {
|
||||||
|
res.set_input("coat_normal", coat_normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.set_input("emission", emission_strength);
|
||||||
|
res.set_input("emission_color", emission);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ NODE_SHADER_MATERIALX_BEGIN
|
|||||||
}
|
}
|
||||||
else if (shader1 && shader2) {
|
else if (shader1 && shader2) {
|
||||||
res = create_node("mix", to_type_);
|
res = create_node("mix", to_type_);
|
||||||
res.set_input("fg", shader1);
|
res.set_input("fg", shader2);
|
||||||
res.set_input("bg", shader2);
|
res.set_input("bg", shader1);
|
||||||
res.set_input("mix", fac);
|
res.set_input("mix", fac);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user