MaterialX: add support for Vector nodes #27

Merged
Bogdan Nagirniak merged 13 commits from Vasyl-Pidhirskyi/blender:BLEN-525 into matx-export-material 2023-09-22 10:03:45 +02:00
4 changed files with 16 additions and 15 deletions
Showing only changes of commit c1f4725826 - Show all commits

View File

@ -81,7 +81,8 @@ NODE_SHADER_MATERIALX_BEGIN
NodeItem location = get_input_value("Location", NodeItem::Type::Vector3); NodeItem location = get_input_value("Location", NodeItem::Type::Vector3);
NodeItem scale = get_input_value("Scale", NodeItem::Type::Vector3); NodeItem scale = get_input_value("Scale", NodeItem::Type::Vector3);
NodeItem vector = get_input_link("Vector", NodeItem::Type::Vector3); NodeItem vector = get_input_link("Vector", NodeItem::Type::Vector3);
NodeItem angle = (get_input_value("Rotation", NodeItem::Type::Vector3) / val(float(M_PI))) * val(180.0f); NodeItem angle = (get_input_value("Rotation", NodeItem::Type::Vector3) / val(float(M_PI))) *
val(180.0f);
MaterialX::Vector3 axis_vector; MaterialX::Vector3 axis_vector;
NodeItem in = empty(); NodeItem in = empty();
const int mode = node_->custom1; const int mode = node_->custom1;
@ -122,19 +123,19 @@ NODE_SHADER_MATERIALX_BEGIN
} }
switch (mode) { switch (mode) {
case NODE_MAPPING_TYPE_POINT: case NODE_MAPPING_TYPE_POINT:
res = res + location; res = res + location;
break; break;
case NODE_MAPPING_TYPE_TEXTURE: case NODE_MAPPING_TYPE_TEXTURE:
res = res / scale; res = res / scale;
break; break;
case NODE_MAPPING_TYPE_NORMAL: case NODE_MAPPING_TYPE_NORMAL:
NodeItem normalize = create_node("normalize", NodeItem::Type::Vector3); NodeItem normalize = create_node("normalize", NodeItem::Type::Vector3);
normalize.set_input("in", res); normalize.set_input("in", res);
res = normalize; res = normalize;
break; break;
} }
return res; return res;
} }

View File

@ -48,7 +48,7 @@ NODE_SHADER_MATERIALX_BEGIN
return res; return res;
} }
return in1; return in1;
} }
#endif #endif
NODE_SHADER_MATERIALX_END NODE_SHADER_MATERIALX_END

View File

@ -233,7 +233,8 @@ NODE_SHADER_MATERIALX_BEGIN
return vector; return vector;
} }
angle = (angle / val(float(M_PI))) * val(180.0f); angle = (angle / val(float(M_PI))) * val(180.0f);
for (int i = node_->custom2 ? 2 : 0; node_->custom2 ? i >= 0 : i <= 2; node_->custom2 ? i-- : i++) { for (int i = node_->custom2 ? 2 : 0; node_->custom2 ? i >= 0 : i <= 2;
node_->custom2 ? i-- : i++) {
axis_vector = MaterialX::Vector3(0.0f, 0.0f, 0.0f); axis_vector = MaterialX::Vector3(0.0f, 0.0f, 0.0f);
int inv = invert; int inv = invert;
if (i == 2) { if (i == 2) {

View File

@ -191,7 +191,6 @@ NODE_SHADER_MATERIALX_BEGIN
#endif #endif
NODE_SHADER_MATERIALX_END NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_vector_transform_cc } // namespace blender::nodes::node_shader_vector_transform_cc
void register_node_type_sh_vect_transform() void register_node_type_sh_vect_transform()