forked from blender/blender
Parsing Improvements #14
@ -16,7 +16,7 @@ NodeItem BSDFDiffuseNodeParser::compute()
|
|||||||
NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
|
NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
|
||||||
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
|
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
|
||||||
|
|
||||||
NodeItem res = create_node("oren_nayar_diffuse_bsdf", "BSDF");
|
NodeItem res = create_node("oren_nayar_diffuse_bsdf", shader_type_);
|
||||||
res.set_input("color", color);
|
res.set_input("color", color);
|
||||||
res.set_input("roughness", roughness);
|
res.set_input("roughness", roughness);
|
||||||
if (normal) {
|
if (normal) {
|
||||||
|
@ -50,7 +50,7 @@ NodeItem BSDFPrincipledNodeParser::compute()
|
|||||||
NodeItem tangent = get_input_link("Tangent", NodeItem::Type::Vector3);
|
NodeItem tangent = get_input_link("Tangent", NodeItem::Type::Vector3);
|
||||||
|
|
||||||
/* Creating standard_surface */
|
/* Creating standard_surface */
|
||||||
NodeItem res = create_node("standard_surface", "surfaceshader");
|
NodeItem res = create_node("standard_surface", shader_type_);
|
||||||
res.set_input("base", 1.0, "float");
|
res.set_input("base", 1.0, "float");
|
||||||
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);
|
||||||
|
@ -15,7 +15,7 @@ NodeItem EmissionNodeParser::compute()
|
|||||||
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
|
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
|
||||||
NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
|
NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
|
||||||
|
|
||||||
NodeItem res = create_node("uniform_edf", "EDF");
|
NodeItem res = create_node("uniform_edf", shader_type_);
|
||||||
res.set_input("color", color * strength);
|
res.set_input("color", color * strength);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ NodeItem HueSatValNodeParser::compute()
|
|||||||
/* Modifier to follow Cycles result */
|
/* Modifier to follow Cycles result */
|
||||||
hue = hue - value(0.5f);
|
hue = hue - value(0.5f);
|
||||||
|
|
||||||
NodeItem combine = create_node("combine3", "vector3");
|
NodeItem combine = create_node("combine3", NodeItem::Type::Vector3);
|
||||||
combine.set_input("in1", hue);
|
combine.set_input("in1", hue);
|
||||||
combine.set_input("in2", saturation);
|
combine.set_input("in2", saturation);
|
||||||
combine.set_input("in3", val);
|
combine.set_input("in3", val);
|
||||||
|
|
||||||
NodeItem res = create_node("hsvadjust", "color3");
|
NodeItem res = create_node("hsvadjust", NodeItem::Type::Color3);
|
||||||
res.set_input("in", color);
|
res.set_input("in", color);
|
||||||
res.set_input("amount", combine);
|
res.set_input("amount", combine);
|
||||||
return res;
|
return res;
|
||||||
|
@ -23,7 +23,7 @@ NodeItem MixShaderNodeParser::compute()
|
|||||||
res = shader2 * fac;
|
res = shader2 * fac;
|
||||||
}
|
}
|
||||||
else if (shader1 && shader2) {
|
else if (shader1 && shader2) {
|
||||||
res = create_node("mix", NodeItem::type(shader_type_));
|
res = create_node("mix", shader_type_);
|
||||||
res.set_input("fg", shader1);
|
res.set_input("fg", shader1);
|
||||||
res.set_input("bg", shader2);
|
res.set_input("bg", shader2);
|
||||||
res.set_input("mix", fac);
|
res.set_input("mix", fac);
|
||||||
|
@ -39,10 +39,10 @@ std::string NodeParser::node_name()
|
|||||||
std::string(node_->name) + "_" + socket_out_->name);
|
std::string(node_->name) + "_" + socket_out_->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem NodeParser::create_node(const std::string &mx_category, const std::string &mx_type)
|
NodeItem NodeParser::create_node(const std::string &mx_category, NodeItem::Type type)
|
||||||
{
|
{
|
||||||
NodeItem res = empty();
|
NodeItem res = empty();
|
||||||
res.node = graph_->addNode(mx_category, MaterialX::EMPTY_STRING, mx_type);
|
res.node = graph_->addNode(mx_category, MaterialX::EMPTY_STRING, NodeItem::type(type));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class NodeParser {
|
|||||||
protected:
|
protected:
|
||||||
virtual NodeItem compute_full();
|
virtual NodeItem compute_full();
|
||||||
virtual std::string node_name();
|
virtual std::string node_name();
|
||||||
NodeItem create_node(const std::string &mx_category, const std::string &mx_type);
|
NodeItem create_node(const std::string &mx_category, NodeItem::Type type);
|
||||||
NodeItem get_input_default(const std::string &name, NodeItem::Type to_type);
|
NodeItem get_input_default(const std::string &name, NodeItem::Type to_type);
|
||||||
NodeItem get_input_default(int index, NodeItem::Type to_type);
|
NodeItem get_input_default(int index, NodeItem::Type to_type);
|
||||||
NodeItem get_input_link(const std::string &name, NodeItem::Type to_type);
|
NodeItem get_input_link(const std::string &name, NodeItem::Type to_type);
|
||||||
|
@ -14,7 +14,7 @@ NodeItem NormalMapNodeParser::compute()
|
|||||||
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
|
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
|
||||||
NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
|
NodeItem strength = get_input_value("Strength", NodeItem::Type::Float);
|
||||||
|
|
||||||
NodeItem res = create_node("normalmap", "vector3");
|
NodeItem res = create_node("normalmap", NodeItem::Type::Vector3);
|
||||||
res.set_input("in", color);
|
res.set_input("in", color);
|
||||||
res.set_input("scale", strength);
|
res.set_input("scale", strength);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ NodeItem OutputMaterialNodeParser::compute()
|
|||||||
NodeItem bsdf = get_input_shader("Surface", NodeItem::Type::BSDF);
|
NodeItem bsdf = get_input_shader("Surface", NodeItem::Type::BSDF);
|
||||||
NodeItem edf = get_input_shader("Surface", NodeItem::Type::EDF);
|
NodeItem edf = get_input_shader("Surface", NodeItem::Type::EDF);
|
||||||
if (bsdf || edf) {
|
if (bsdf || edf) {
|
||||||
surface = create_node("surface", "surfaceshader");
|
surface = create_node("surface", NodeItem::Type::SurfaceShader);
|
||||||
if (bsdf) {
|
if (bsdf) {
|
||||||
surface.set_input("bsdf", bsdf);
|
surface.set_input("bsdf", bsdf);
|
||||||
}
|
}
|
||||||
@ -33,17 +33,17 @@ NodeItem OutputMaterialNodeParser::compute()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
surface = create_node("standard_surface", "surfaceshader");
|
surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
||||||
surface.set_input("base_color", value(MaterialX::Color3(1.0f, 0.0f, 1.0f)));
|
surface.set_input("base_color", value(MaterialX::Color3(1.0f, 0.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
NodeItem res = create_node("surfacematerial", "material");
|
NodeItem res = create_node("surfacematerial", shader_type_);
|
||||||
res.set_input("surfaceshader", surface);
|
res.set_input("surfaceshader", surface);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem OutputMaterialNodeParser::compute_default()
|
NodeItem OutputMaterialNodeParser::compute_default()
|
||||||
{
|
{
|
||||||
NodeItem surface = create_node("standard_surface", "surfaceshader");
|
NodeItem surface = create_node("standard_surface", NodeItem::Type::SurfaceShader);
|
||||||
surface.set_input("base_color",
|
surface.set_input("base_color",
|
||||||
value(MaterialX::Color3(material_->r, material_->g, material_->b)));
|
value(MaterialX::Color3(material_->r, material_->g, material_->b)));
|
||||||
surface.set_input("diffuse_roughness", value(material_->roughness));
|
surface.set_input("diffuse_roughness", value(material_->roughness));
|
||||||
@ -56,7 +56,7 @@ NodeItem OutputMaterialNodeParser::compute_default()
|
|||||||
surface.set_input("specular_roughness", value(material_->roughness));
|
surface.set_input("specular_roughness", value(material_->roughness));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem res = create_node("surfacematerial", "material");
|
NodeItem res = create_node("surfacematerial", shader_type_);
|
||||||
res.node->setName("Material_Default");
|
res.node->setName("Material_Default");
|
||||||
res.set_input("surfaceshader", surface);
|
res.set_input("surfaceshader", surface);
|
||||||
return res;
|
return res;
|
||||||
|
@ -18,12 +18,12 @@ NodeItem SeparateColorNodeParser::compute()
|
|||||||
case NODE_COMBSEP_COLOR_RGB:
|
case NODE_COMBSEP_COLOR_RGB:
|
||||||
break;
|
break;
|
||||||
case NODE_COMBSEP_COLOR_HSV:
|
case NODE_COMBSEP_COLOR_HSV:
|
||||||
convert = create_node("rgbtohsv", "color3");
|
convert = create_node("rgbtohsv", NodeItem::Type::Color3);
|
||||||
convert.set_input("in", color);
|
convert.set_input("in", color);
|
||||||
break;
|
break;
|
||||||
case NODE_COMBSEP_COLOR_HSL:
|
case NODE_COMBSEP_COLOR_HSL:
|
||||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
|
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
|
||||||
convert = create_node("rgbtohsv", "color3");
|
convert = create_node("rgbtohsv", NodeItem::Type::Color3);
|
||||||
convert.set_input("in", color);
|
convert.set_input("in", color);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -44,7 +44,7 @@ NodeItem CombineColorNodeParser::compute()
|
|||||||
NodeItem blue = get_input_value("Blue", NodeItem::Type::Float);
|
NodeItem blue = get_input_value("Blue", NodeItem::Type::Float);
|
||||||
|
|
||||||
NodeItem convert = empty();
|
NodeItem convert = empty();
|
||||||
NodeItem combine = create_node("combine3", "color3");
|
NodeItem combine = create_node("combine3", NodeItem::Type::Color3);
|
||||||
combine.set_input("in1", red);
|
combine.set_input("in1", red);
|
||||||
combine.set_input("in2", green);
|
combine.set_input("in2", green);
|
||||||
combine.set_input("in3", blue);
|
combine.set_input("in3", blue);
|
||||||
@ -53,12 +53,12 @@ NodeItem CombineColorNodeParser::compute()
|
|||||||
case NODE_COMBSEP_COLOR_RGB:
|
case NODE_COMBSEP_COLOR_RGB:
|
||||||
break;
|
break;
|
||||||
case NODE_COMBSEP_COLOR_HSV:
|
case NODE_COMBSEP_COLOR_HSV:
|
||||||
convert = create_node("hsvtorgb", "color3");
|
convert = create_node("hsvtorgb", NodeItem::Type::Color3);
|
||||||
convert.set_input("in", combine);
|
convert.set_input("in", combine);
|
||||||
break;
|
break;
|
||||||
case NODE_COMBSEP_COLOR_HSL:
|
case NODE_COMBSEP_COLOR_HSL:
|
||||||
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
|
CLOG_WARN(LOG_MATERIALX_SHADER, "Unsupported color model, using HSV instead: %d", mode);
|
||||||
convert = create_node("hsvtorgb", "color3");
|
convert = create_node("hsvtorgb", NodeItem::Type::Color3);
|
||||||
convert.set_input("in", combine);
|
convert.set_input("in", combine);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -18,7 +18,7 @@ NodeItem CombineXYZNodeParser::compute()
|
|||||||
NodeItem x = get_input_value("X", NodeItem::Type::Float);
|
NodeItem x = get_input_value("X", NodeItem::Type::Float);
|
||||||
NodeItem y = get_input_value("Y", NodeItem::Type::Float);
|
NodeItem y = get_input_value("Y", NodeItem::Type::Float);
|
||||||
NodeItem z = get_input_value("Z", NodeItem::Type::Float);
|
NodeItem z = get_input_value("Z", NodeItem::Type::Float);
|
||||||
NodeItem res = create_node("combine3", "vector3");
|
NodeItem res = create_node("combine3", NodeItem::Type::Vector3);
|
||||||
res.set_input("in1", x);
|
res.set_input("in1", x);
|
||||||
res.set_input("in2", y);
|
res.set_input("in2", y);
|
||||||
res.set_input("in3", z);
|
res.set_input("in3", z);
|
||||||
|
@ -14,12 +14,12 @@ NodeItem TexCheckerNodeParser::compute()
|
|||||||
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
|
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
|
||||||
|
|
||||||
if (!vector) {
|
if (!vector) {
|
||||||
vector = create_node("texcoord", "vector2");
|
vector = create_node("texcoord", NodeItem::Type::Vector2);
|
||||||
}
|
}
|
||||||
vector = (vector * scale) % value(2.0f);
|
vector = (vector * scale) % value(2.0f);
|
||||||
NodeItem mix = (vector.extract(0).floor() + vector.extract(1).floor())
|
NodeItem mix = (vector.extract(0).floor() + vector.extract(1).floor())
|
||||||
.if_else(NodeItem::CompareOp::Eq, value(1.0f), value(1.0f), value(0.0f));
|
.if_else(NodeItem::CompareOp::Eq, value(1.0f), value(1.0f), value(0.0f));
|
||||||
NodeItem res = create_node("mix", "color3");
|
NodeItem res = create_node("mix", NodeItem::Type::Color3);
|
||||||
res.set_input("fg", color1);
|
res.set_input("fg", color1);
|
||||||
res.set_input("bg", color2);
|
res.set_input("bg", color2);
|
||||||
res.set_input("mix", mix);
|
res.set_input("mix", mix);
|
||||||
|
@ -23,8 +23,8 @@ NodeItem TexEnvironmentNodeParser::compute()
|
|||||||
image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
|
image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NodeItem texcoord = create_node("texcoord", "vector2");
|
NodeItem texcoord = create_node("texcoord", NodeItem::Type::Vector2);
|
||||||
NodeItem res = create_node("image", "color3");
|
NodeItem res = create_node("image", NodeItem::Type::Color3);
|
||||||
res.set_input("file", image_path, "filename");
|
res.set_input("file", image_path, "filename");
|
||||||
res.set_input("texcoord", texcoord);
|
res.set_input("texcoord", texcoord);
|
||||||
return res;
|
return res;
|
||||||
|
@ -23,8 +23,8 @@ NodeItem TexImageNodeParser::compute()
|
|||||||
image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
|
image_path = io::hydra::cache_or_get_image_file(bmain, scene, image, &tex->iuser);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NodeItem texcoord = create_node("texcoord", "vector2");
|
NodeItem texcoord = create_node("texcoord", NodeItem::Type::Vector2);
|
||||||
NodeItem res = create_node("image", "color3");
|
NodeItem res = create_node("image", NodeItem::Type::Color3);
|
||||||
res.set_input("file", image_path, "filename");
|
res.set_input("file", image_path, "filename");
|
||||||
res.set_input("texcoord", texcoord);
|
res.set_input("texcoord", texcoord);
|
||||||
return res;
|
return res;
|
||||||
|
@ -16,10 +16,10 @@ NodeItem TexNoiseNodeParser::compute()
|
|||||||
detail = value(int(detail.value->asA<float>()));
|
detail = value(int(detail.value->asA<float>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem position = create_node("position", "vector3");
|
NodeItem position = create_node("position", NodeItem::Type::Vector3);
|
||||||
position = position * scale;
|
position = position * scale;
|
||||||
|
|
||||||
NodeItem res = create_node("fractal3d", "color3");
|
NodeItem res = create_node("fractal3d", NodeItem::Type::Color3);
|
||||||
res.set_input("position", position);
|
res.set_input("position", position);
|
||||||
res.set_input("octaves", detail);
|
res.set_input("octaves", detail);
|
||||||
res.set_input("lacunarity", lacunarity);
|
res.set_input("lacunarity", lacunarity);
|
||||||
|
Loading…
Reference in New Issue
Block a user