forked from blender/blender
Implement BSDF Transparent shader #36
@ -54,7 +54,7 @@ NodeItem::Type NodeItem::type(const std::string &type_str)
|
||||
return Type::EDF;
|
||||
}
|
||||
if (type_str == "displacementshader") {
|
||||
return Type::Displacementshader;
|
||||
return Type::DisplacementShader;
|
||||
}
|
||||
if (type_str == "surfaceshader") {
|
||||
return Type::SurfaceShader;
|
||||
@ -97,7 +97,7 @@ std::string NodeItem::type(Type type)
|
||||
return "BSDF";
|
||||
case Type::EDF:
|
||||
return "EDF";
|
||||
case Type::Displacementshader:
|
||||
case Type::DisplacementShader:
|
||||
return "displacementshader";
|
||||
case Type::SurfaceShader:
|
||||
return "surfaceshader";
|
||||
@ -388,14 +388,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
|
||||
|
@ -41,7 +41,7 @@ class NodeItem {
|
||||
/* Shader types. NOTE: There are only supported types */
|
||||
BSDF,
|
||||
EDF,
|
||||
Displacementshader,
|
||||
DisplacementShader,
|
||||
SurfaceShader,
|
||||
Material,
|
||||
|
||||
|
@ -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
|
||||
|
@ -58,10 +58,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
|
||||
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
|
||||
|
||||
return create_node(
|
||||
"sheen_bsdf",
|
||||
return create_node("sheen_bsdf",
|
||||
NodeItem::Type::BSDF,
|
||||
{{"color", color}, {"weight", roughness}, {"roughness", roughness}, {"normal", normal}});
|
||||
{{"color", color}, {"roughness", roughness}, {"normal", normal}});
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
@ -46,7 +46,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
|
||||
|
||||
return create_node("displacement",
|
||||
NodeItem::Type::Displacementshader,
|
||||
NodeItem::Type::DisplacementShader,
|
||||
{{"displacement", height}, {"scale", scale}});
|
||||
}
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -50,7 +50,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
|
||||
|
||||
return create_node("displacement",
|
||||
NodeItem::Type::Displacementshader,
|
||||
NodeItem::Type::DisplacementShader,
|
||||
{{"displacement", vector}, {"scale", scale}});
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user