MaterialX: code improvements shader modes. #35

Merged
3 changed files with 16 additions and 32 deletions
Showing only changes of commit 541c4de724 - Show all commits

View File

@ -327,7 +327,6 @@ NodeItem NodeItem::dotproduct(const NodeItem &other) const
NodeItem item1 = to_vector();
NodeItem item2 = other.to_vector();
cast_types(item1, item2);
return create_node("dotproduct", Type::Float, {{"in1", item1}, {"in2", item2}});
}
@ -388,14 +387,15 @@ NodeItem NodeItem::rotate(const NodeItem &angle_xyz, bool invert)
NodeItem x = angle_xyz[0];
NodeItem y = angle_xyz[1];
NodeItem z = angle_xyz[2];
NodeItem x_axis = val(MaterialX::Vector3(1.0f, 0.0f, 0.0f));
NodeItem y_axis = val(MaterialX::Vector3(0.0f, 1.0f, 0.0f));
NodeItem z_axis = val(MaterialX::Vector3(0.0f, 0.0f, 1.0f));
if (invert) {
return rotate(z, val(MaterialX::Vector3(0.0f, 0.0f, 1.0f)))
.rotate(y, val(MaterialX::Vector3(0.0f, 1.0f, 0.0f)))
.rotate(x, val(MaterialX::Vector3(1.0f, 0.0f, 0.0f)));
return rotate(z, z_axis).rotate(y, y_axis).rotate(x, x_axis);
}
return rotate(x, val(MaterialX::Vector3(1.0f, 0.0f, 0.0f)))
.rotate(y, val(MaterialX::Vector3(0.0f, 1.0f, 0.0f)))
.rotate(z, val(MaterialX::Vector3(0.0f, 0.0f, 1.0f)));
return rotate(x, x_axis).rotate(y, y_axis).rotate(z, z_axis);
}
NodeItem NodeItem::sin() const

View File

@ -54,29 +54,13 @@ NODE_SHADER_MATERIALX_BEGIN
NodeItem ior = get_input_value("IOR", NodeItem::Type::Float);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
NodeItem dielectric = create_node("dielectric_bsdf",
return create_node("dielectric_bsdf",
NodeItem::Type::BSDF,
{{"normal", normal},
{"tint", color},
{"roughness", roughness},
{"ior", ior},
{"scatter_mode", val(std::string("RT"))}});
NodeItem artistic_ior = create_node("artistic_ior",
NodeItem::Type::Multioutput,
{{"reflectivity", color}, {"edge_color", color}});
NodeItem ior_out = artistic_ior.add_output("ior", NodeItem::Type::Color3);
NodeItem extinction_out = artistic_ior.add_output("extinction", NodeItem::Type::Color3);
NodeItem conductor = create_node("conductor_bsdf",
NodeItem::Type::BSDF,
{{"normal", normal},
{"ior", ior_out},
{"extinction", extinction_out},
{"roughness", roughness}});
return create_node(
"mix", NodeItem::Type::BSDF, {{"fg", dielectric}, {"bg", conductor}, {"mix", val(0.5f)}});
}
#endif
NODE_SHADER_MATERIALX_END

View File

@ -89,8 +89,8 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* TODO: This node doesn't have an implementation in MaterialX.*/
return get_output_default(socket_out_->name, NodeItem::Type::Vector3);
/* TODO: implement other features */
return create_node("tangent", NodeItem::Type::Vector3, {{"space", val(std::string("world"))}});
}
#endif
NODE_SHADER_MATERIALX_END