|
|
@ -8,22 +8,7 @@ namespace blender::nodes::materialx {
|
|
|
|
|
|
|
|
|
|
|
|
NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto enabled = [](NodeItem &val) -> bool {
|
|
|
|
NodeItem zero = value(0.0f);
|
|
|
|
if (val.node) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!val.value) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val.value->isA<float>()) {
|
|
|
|
|
|
|
|
return val.value->asA<float>() != 0.0f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val.value->isA<MaterialX::Color4>()) {
|
|
|
|
|
|
|
|
auto c = val.value->asA<MaterialX::Color4>();
|
|
|
|
|
|
|
|
return c[0] != 0.0f || c[1] != 0.0f || c[2] != 0.0f;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Getting required inputs
|
|
|
|
/* Getting required inputs
|
|
|
|
* Note: if some inputs are not needed they won't be taken */
|
|
|
|
* Note: if some inputs are not needed they won't be taken */
|
|
|
@ -32,7 +17,7 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
NodeItem subsurface = get_input_value("Subsurface");
|
|
|
|
NodeItem subsurface = get_input_value("Subsurface");
|
|
|
|
NodeItem subsurface_radius = empty();
|
|
|
|
NodeItem subsurface_radius = empty();
|
|
|
|
NodeItem subsurface_color = empty();
|
|
|
|
NodeItem subsurface_color = empty();
|
|
|
|
if (enabled(subsurface)) {
|
|
|
|
if (subsurface != zero) {
|
|
|
|
subsurface_radius = get_input_value("Subsurface Radius");
|
|
|
|
subsurface_radius = get_input_value("Subsurface Radius");
|
|
|
|
subsurface_color = get_input_value("Subsurface Color");
|
|
|
|
subsurface_color = get_input_value("Subsurface Color");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -44,10 +29,10 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
|
|
|
|
|
|
|
|
NodeItem anisotropic = empty();
|
|
|
|
NodeItem anisotropic = empty();
|
|
|
|
NodeItem anisotropic_rotation = empty();
|
|
|
|
NodeItem anisotropic_rotation = empty();
|
|
|
|
if (enabled(metallic)) {
|
|
|
|
if (metallic != zero) {
|
|
|
|
/* TODO: use Specular Tint input */
|
|
|
|
/* TODO: use Specular Tint input */
|
|
|
|
anisotropic = get_input_value("Anisotropic");
|
|
|
|
anisotropic = get_input_value("Anisotropic");
|
|
|
|
if (enabled(anisotropic)) {
|
|
|
|
if (anisotropic != zero) {
|
|
|
|
anisotropic_rotation = get_input_value("Anisotropic Rotation");
|
|
|
|
anisotropic_rotation = get_input_value("Anisotropic Rotation");
|
|
|
|
// anisotropic_rotation = 0.5 - (anisotropic_rotation % 1.0)
|
|
|
|
// anisotropic_rotation = 0.5 - (anisotropic_rotation % 1.0)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -60,7 +45,7 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
|
|
|
|
|
|
|
|
NodeItem clearcoat = get_input_value("Clearcoat");
|
|
|
|
NodeItem clearcoat = get_input_value("Clearcoat");
|
|
|
|
NodeItem clearcoat_roughness = empty();
|
|
|
|
NodeItem clearcoat_roughness = empty();
|
|
|
|
if (enabled(clearcoat)) {
|
|
|
|
if (clearcoat != zero) {
|
|
|
|
clearcoat_roughness = get_input_value("Clearcoat Roughness");
|
|
|
|
clearcoat_roughness = get_input_value("Clearcoat Roughness");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -68,7 +53,7 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
|
|
|
|
|
|
|
|
NodeItem transmission = get_input_value("Transmission");
|
|
|
|
NodeItem transmission = get_input_value("Transmission");
|
|
|
|
NodeItem transmission_roughness = empty();
|
|
|
|
NodeItem transmission_roughness = empty();
|
|
|
|
if (enabled(transmission)) {
|
|
|
|
if (transmission != zero) {
|
|
|
|
transmission_roughness = get_input_value("Transmission Roughness");
|
|
|
|
transmission_roughness = get_input_value("Transmission Roughness");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -90,11 +75,11 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
res.set_input("normal", normal);
|
|
|
|
res.set_input("normal", normal);
|
|
|
|
res.set_input("tangent", tangent);
|
|
|
|
res.set_input("tangent", tangent);
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(metallic)) {
|
|
|
|
if (metallic != zero) {
|
|
|
|
res.set_input("metalness", metallic);
|
|
|
|
res.set_input("metalness", metallic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(specular)) {
|
|
|
|
if (specular != zero) {
|
|
|
|
res.set_input("specular", specular);
|
|
|
|
res.set_input("specular", specular);
|
|
|
|
res.set_input("specular_color", base_color.to_color3());
|
|
|
|
res.set_input("specular_color", base_color.to_color3());
|
|
|
|
res.set_input("specular_roughness", roughness);
|
|
|
|
res.set_input("specular_roughness", roughness);
|
|
|
@ -103,26 +88,26 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
res.set_input("specular_rotation", anisotropic_rotation);
|
|
|
|
res.set_input("specular_rotation", anisotropic_rotation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(transmission)) {
|
|
|
|
if (transmission != zero) {
|
|
|
|
res.set_input("transmission", transmission);
|
|
|
|
res.set_input("transmission", transmission);
|
|
|
|
res.set_input("transmission_color", base_color.to_color3());
|
|
|
|
res.set_input("transmission_color", base_color.to_color3());
|
|
|
|
res.set_input("transmission_extra_roughness", transmission_roughness);
|
|
|
|
res.set_input("transmission_extra_roughness", transmission_roughness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(subsurface)) {
|
|
|
|
if (subsurface != zero) {
|
|
|
|
res.set_input("subsurface", subsurface);
|
|
|
|
res.set_input("subsurface", subsurface);
|
|
|
|
res.set_input("subsurface_color", subsurface_color);
|
|
|
|
res.set_input("subsurface_color", subsurface_color);
|
|
|
|
res.set_input("subsurface_radius", subsurface_radius);
|
|
|
|
res.set_input("subsurface_radius", subsurface_radius);
|
|
|
|
res.set_input("subsurface_anisotropy", anisotropic);
|
|
|
|
res.set_input("subsurface_anisotropy", anisotropic);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(sheen)) {
|
|
|
|
if (sheen != zero) {
|
|
|
|
res.set_input("sheen", sheen);
|
|
|
|
res.set_input("sheen", sheen);
|
|
|
|
res.set_input("sheen_color", base_color.to_color3());
|
|
|
|
res.set_input("sheen_color", base_color.to_color3());
|
|
|
|
res.set_input("sheen_roughness", roughness);
|
|
|
|
res.set_input("sheen_roughness", roughness);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(clearcoat)) {
|
|
|
|
if (clearcoat != zero) {
|
|
|
|
res.set_input("coat", clearcoat);
|
|
|
|
res.set_input("coat", clearcoat);
|
|
|
|
res.set_input("coat_color", base_color.to_color3());
|
|
|
|
res.set_input("coat_color", base_color.to_color3());
|
|
|
|
res.set_input("coat_roughness", clearcoat_roughness);
|
|
|
|
res.set_input("coat_roughness", clearcoat_roughness);
|
|
|
@ -132,7 +117,7 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|
|
|
res.set_input("coat_normal", clearcoat_normal);
|
|
|
|
res.set_input("coat_normal", clearcoat_normal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled(emission)) {
|
|
|
|
if (emission != zero) {
|
|
|
|
res.set_input("emission", emission_strength);
|
|
|
|
res.set_input("emission", emission_strength);
|
|
|
|
res.set_input("emission_color", emission);
|
|
|
|
res.set_input("emission_color", emission);
|
|
|
|
}
|
|
|
|
}
|
|
|
|