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 NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #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); return get_input_link("Normal", NodeItem::Type::Vector3);
} }
#endif #endif

View File

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

View File

@ -61,7 +61,7 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #ifdef WITH_MATERIALX
{ {
/* NOTE: Some outputs don't have an implementation in MaterialX.*/ /* NOTE: Some outputs aren't supported by MaterialX.*/
NodeItem res = empty(); NodeItem res = empty();
std::string name = socket_out_->name; 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 NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #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")) { if (STREQ(socket_out_->name, "Is Camera Ray")) {
return val(1.0f); return val(1.0f);
} }

View File

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

View File

@ -37,7 +37,7 @@ static int gpu_shader_particle_info(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #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); return get_output_default(socket_out_->name, NodeItem::Type::Any);
} }
#endif #endif

View File

@ -25,7 +25,7 @@ static int node_shader_gpu_point_info(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #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); return get_output_default(socket_out_->name, NodeItem::Type::Any);
} }
#endif #endif

View File

@ -74,7 +74,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat,
NODE_SHADER_MATERIALX_BEGIN NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #ifdef WITH_MATERIALX
{ {
/* NOTE: Some outputs don't have an implementation in MaterialX.*/ /* NOTE: Some outputs aren't supported by MaterialX.*/
NodeItem res = empty(); NodeItem res = empty();
std::string name = socket_out_->name; 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 NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #ifdef WITH_MATERIALX
{ {
/* NOTE: Some inputs aren't supported by MaterialX.*/
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float); NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
NodeItem detail = get_input_default("Detail", NodeItem::Type::Float); NodeItem detail = get_input_default("Detail", NodeItem::Type::Float);
NodeItem lacunarity = get_input_value("Lacunarity", 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 NODE_SHADER_MATERIALX_BEGIN
#ifdef WITH_MATERIALX #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); return get_output_default(socket_out_->name, NodeItem::Type::Float);
} }
#endif #endif