MaterialX: code improvements #34

Merged
Bogdan Nagirniak merged 2 commits from matx-nodes-polishing into matx-export-material 2023-09-26 07:29:05 +02:00
10 changed files with 44 additions and 41 deletions

View File

@ -42,7 +42,7 @@ static int gpu_shader_bevel(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: This node doesn't have an implementation in MaterialX.*/
/* NOTE: This node isn't supported by MaterialX.*/
return get_input_link("Normal", NodeItem::Type::Vector3);
}
#endif

View File

@ -525,39 +525,41 @@ NODE_SHADER_MATERIALX_BEGIN
NodeItem anisotropic = in["anisotropic"];
NodeItem rotation = in["anisotropic_rotation"];
res = create_node("standard_surface",
NodeItem::Type::SurfaceShader,
{{"base", val(1.0f)},
{"base_color", base_color},
{"diffuse_roughness", roughness},
{"metalness", in["metallic"]},
{"specular", in["specular"]},
{"specular_color", in["specular_tint"]},
{"specular_roughness", roughness},
{"specular_IOR", in["ior"]},
{"specular_anisotropy", anisotropic},
{"specular_rotation", rotation},
{"transmission", in["transmission"]},
{"transmission_color", base_color},
{"transmission_extra_roughness", roughness},
{"subsurface", in["subsurface"]},
{"subsurface_color", base_color},
{"subsurface_radius", in["subsurface_radius"] * in["subsurface_scale"]},
{"subsurface_anisotropy", in["subsurface_anisotropy"]},
{"sheen", in["sheen"]},
{"sheen_color", in["sheen_tint"]},
{"sheen_roughness", in["sheen_roughness"]},
{"coat", in["coat"]},
{"coat_color", in["coat_tint"]},
{"coat_roughness", in["coat_roughness"]},
{"coat_IOR", in["coat_ior"]},
{"coat_anisotropy", anisotropic},
{"coat_rotation", rotation},
{"coat_normal", in["coat_normal"]},
{"emission", in["emission"]},
{"emission_color", in["emission_color"]},
{"normal", in["normal"]},
{"tangent", in["tangent"]}});
res = create_node(
"standard_surface",
NodeItem::Type::SurfaceShader,
{{"base", val(1.0f)},
{"base_color", base_color},
{"diffuse_roughness", roughness},
{"metalness", in["metallic"]},
{"specular", in["specular"]},
{"specular_color", in["specular_tint"]},
{"specular_roughness", roughness},
{"specular_IOR", in["ior"]},
{"specular_anisotropy", anisotropic},
{"specular_rotation", rotation},
{"transmission", in["transmission"]},
{"transmission_color", base_color},
{"transmission_extra_roughness", roughness},
{"subsurface", in["subsurface"]},
{"subsurface_color", base_color},
{"subsurface_radius",
(in["subsurface_radius"] * in["subsurface_scale"]).convert(NodeItem::Type::Color3)},
{"subsurface_anisotropy", in["subsurface_anisotropy"]},
{"sheen", in["sheen"]},
{"sheen_color", in["sheen_tint"]},
{"sheen_roughness", in["sheen_roughness"]},
{"coat", in["coat"]},
{"coat_color", in["coat_tint"]},
{"coat_roughness", in["coat_roughness"]},
{"coat_IOR", in["coat_ior"]},
{"coat_anisotropy", anisotropic},
{"coat_rotation", rotation},
{"coat_normal", in["coat_normal"]},
{"emission", in["emission"]},
{"emission_color", in["emission_color"]},
{"normal", in["normal"]},
{"tangent", in["tangent"]}});
break;
}
default:

View File

@ -61,7 +61,7 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: Some outputs don't have an implementation in MaterialX.*/
/* NOTE: Some outputs aren't supported by MaterialX.*/
NodeItem res = empty();
std::string name = socket_out_->name;

View File

@ -35,7 +35,7 @@ static int node_shader_gpu_light_path(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* This node isn't supported by MaterialX. Only default values returned. */
/* NOTE: This node isn't supported by MaterialX. Only default values returned. */
if (STREQ(socket_out_->name, "Is Camera Ray")) {
return val(1.0f);
}

View File

@ -33,7 +33,7 @@ static int node_shader_gpu_object_info(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: Some outputs don't have an implementation in MaterialX.*/
/* NOTE: Some outputs isn't supported by MaterialX.*/
NodeItem res = empty();
std::string name = socket_out_->name;

View File

@ -37,7 +37,7 @@ static int gpu_shader_particle_info(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: This node doesn't have an implementation in MaterialX.*/
/* NOTE: This node isn't supported by MaterialX.*/
return get_output_default(socket_out_->name, NodeItem::Type::Any);
}
#endif

View File

@ -25,7 +25,7 @@ static int node_shader_gpu_point_info(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: This node doesn't have an implementation in MaterialX.*/
/* NOTE: This node isn't supported by MaterialX.*/
return get_output_default(socket_out_->name, NodeItem::Type::Any);
}
#endif

View File

@ -74,7 +74,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: Some outputs don't have an implementation in MaterialX.*/
/* NOTE: Some outputs aren't supported by MaterialX.*/
NodeItem res = empty();
std::string name = socket_out_->name;

View File

@ -260,6 +260,7 @@ static void sh_node_noise_build_multi_function(NodeMultiFunctionBuilder &builder
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: Some inputs aren't supported by MaterialX.*/
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
NodeItem detail = get_input_default("Detail", NodeItem::Type::Float);
NodeItem lacunarity = get_input_value("Lacunarity", NodeItem::Type::Float);

View File

@ -43,7 +43,7 @@ static int node_shader_gpu_wireframe(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX
{
/* NOTE: This node doesn't have an implementation in MaterialX.*/
/* NOTE: This node isn't supported by MaterialX.*/
return get_output_default(socket_out_->name, NodeItem::Type::Float);
}
#endif