MaterialX: Implement more shader nodes #23

Merged
Bogdan Nagirniak merged 4 commits from matx-add-other-shader-nodes into matx-export-material 2023-09-15 20:11:01 +02:00
Showing only changes of commit 4c97c7d402 - Show all commits

View File

@ -42,6 +42,45 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_constant(&use_multi_scatter)); return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_constant(&use_multi_scatter));
} }
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
if (to_type_ != NodeItem::Type::SurfaceShader) {
/* TODO: implement for BSDF and EDF */
return empty();
}
NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
NodeItem roughness = get_input_value("Roughness", NodeItem::Type::Float);
NodeItem ior = get_input_value("IOR", NodeItem::Type::Float);
NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
NodeItem res = create_node("standard_surface", NodeItem::Type::SurfaceShader);
res.set_input("base", val(1.0f));
if (normal) {
res.set_input("normal", normal);
}
res.set_input("base_color", color);
res.set_input("diffuse_roughness", roughness);
res.set_input("metalness", val(0.0f));
res.set_input("specular", val(0.5f));
res.set_input("specular_color", color);
res.set_input("specular_roughness", roughness);
res.set_input("specular_IOR", ior);
res.set_input("specular_anisotropy", val(0.0f));
res.set_input("specular_rotation", val(0.0f));
res.set_input("transmission", val(1.0f));
res.set_input("transmission_color", color);
res.set_input("transmission_depth", val(10.0f));
res.set_input("transmission_scatter_anisotropy", val(0.0f));
res.set_input("transmission_dispersion", val(0.0f));
res.set_input("transmission_extra_roughness", val(0.0f));
return res;
}
Review

Dielectric already has Reflection and Transmission channels (dielectric -> scatter_mode = "RT"). Do we need one more mix with the Reflection channel (conductor)?

Dielectric already has Reflection and Transmission channels (dielectric -> scatter_mode = "RT"). Do we need one more mix with the Reflection channel (conductor)?
#endif
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_bsdf_glass_cc } // namespace blender::nodes::node_shader_bsdf_glass_cc
/* node type definition */ /* node type definition */
@ -57,6 +96,7 @@ void register_node_type_sh_bsdf_glass()
blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE); blender::bke::node_type_size_preset(&ntype, blender::bke::eNodeSizePreset::MIDDLE);
ntype.initfunc = file_ns::node_shader_init_glass; ntype.initfunc = file_ns::node_shader_init_glass;
ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_glass; ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_glass;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype); nodeRegisterType(&ntype);
} }