forked from blender/blender
MaterialX: Implement more shader nodes #23
@ -45,32 +45,44 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat,
|
|||||||
NODE_SHADER_MATERIALX_BEGIN
|
NODE_SHADER_MATERIALX_BEGIN
|
||||||
#ifdef WITH_MATERIALX
|
#ifdef WITH_MATERIALX
|
||||||
{
|
{
|
||||||
if (to_type_ != NodeItem::Type::SurfaceShader) {
|
if (to_type_ != NodeItem::Type::BSDF) {
|
||||||
/* TODO: implement for BSDF and EDF */
|
|
||||||
return empty();
|
return empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
|
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
|
||||||
NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
|
NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Vector2);
|
||||||
NodeItem ior = get_input_value("IOR", NodeItem::Type::Float);
|
NodeItem ior = get_input_value("IOR", 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("standard_surface", NodeItem::Type::SurfaceShader);
|
NodeItem dielectric = create_node("dielectric_bsdf", NodeItem::Type::BSDF);
|
||||||
res.set_input("base", val(1.0f));
|
|
||||||
if (normal) {
|
if (normal) {
|
||||||
res.set_input("normal", normal);
|
dielectric.set_input("normal", normal);
|
||||||
}
|
}
|
||||||
res.set_input("base_color", color);
|
dielectric.set_input("tint", color);
|
||||||
res.set_input("diffuse_roughness", roughness);
|
dielectric.set_input("roughness", roughness);
|
||||||
res.set_input("specular", val(0.5f));
|
dielectric.set_input("ior", ior);
|
||||||
res.set_input("specular_color", color);
|
dielectric.set_input("scatter_mode", val(std::string("RT")));
|
||||||
res.set_input("specular_roughness", roughness);
|
|
||||||
res.set_input("specular_IOR", ior);
|
|
||||||
res.set_input("transmission", val(1.0f));
|
|
||||||
res.set_input("transmission_color", color);
|
|
||||||
res.set_input("transmission_depth", val(10.0f));
|
|
||||||
|
|
||||||
return res;
|
NodeItem artistic_ior = create_node("artistic_ior", NodeItem::Type::Multioutput);
|
||||||
|
artistic_ior.add_output("ior", NodeItem::Type::Color3);
|
||||||
|
artistic_ior.add_output("extinction", NodeItem::Type::Color3);
|
||||||
|
artistic_ior.set_input("reflectivity", color);
|
||||||
|
artistic_ior.set_input("edge_color", color);
|
||||||
|
|
||||||
|
NodeItem conductor = create_node("conductor_bsdf", NodeItem::Type::BSDF);
|
||||||
|
if (normal) {
|
||||||
|
conductor.set_input("normal", normal);
|
||||||
|
}
|
||||||
|
conductor.set_input_output("ior", artistic_ior, "ior");
|
||||||
|
conductor.set_input_output("extinction", artistic_ior, "extinction");
|
||||||
|
conductor.set_input("roughness", roughness);
|
||||||
|
|
||||||
|
NodeItem res = create_node("mix", NodeItem::Type::BSDF);
|
||||||
|
|||||||
|
res.set_input("fg", dielectric);
|
||||||
|
res.set_input("bg", conductor);
|
||||||
|
res.set_input("mix", val(0.5f));
|
||||||
|
|
||||||
|
return res ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
NODE_SHADER_MATERIALX_END
|
NODE_SHADER_MATERIALX_END
|
||||||
|
Loading…
Reference in New Issue
Block a user
Dielectric already has Reflection and Transmission channels (dielectric -> scatter_mode = "RT"). Do we need one more mix with the Reflection channel (conductor)?