Code improvements + Mix node #30

Merged
Bogdan Nagirniak merged 18 commits from BogdanNagirniak/blender:matx-code-improvements into matx-export-material 2023-09-22 18:23:13 +02:00
3 changed files with 9 additions and 8 deletions
Showing only changes of commit aaa31cdd9d - Show all commits

View File

@ -291,31 +291,31 @@ NodeItem NodeItem::dotproduct(const NodeItem &other) const
float f = 0.0f; float f = 0.0f;
switch (d.type()) { switch (d.type()) {
case Type::Float: { case Type::Float: {
f = value->asA<float>(); f = d.value->asA<float>();
break; break;
} }
case Type::Vector2: { case Type::Vector2: {
auto v = value->asA<MaterialX::Vector2>(); auto v = d.value->asA<MaterialX::Vector2>();
f = v[0] + v[1]; f = v[0] + v[1];
break; break;
} }
case Type::Vector3: { case Type::Vector3: {
auto v = value->asA<MaterialX::Vector3>(); auto v = d.value->asA<MaterialX::Vector3>();
f = v[0] + v[1] + v[2]; f = v[0] + v[1] + v[2];
break; break;
} }
case Type::Vector4: { case Type::Vector4: {
auto v = value->asA<MaterialX::Vector4>(); auto v = d.value->asA<MaterialX::Vector4>();
f = v[0] + v[1] + v[2] + v[3]; f = v[0] + v[1] + v[2] + v[3];
break; break;
} }
case Type::Color3: { case Type::Color3: {
auto v = value->asA<MaterialX::Color3>(); auto v = d.value->asA<MaterialX::Color3>();
f = v[0] + v[1] + v[2]; f = v[0] + v[1] + v[2];
break; break;
} }
case Type::Color4: { case Type::Color4: {
auto v = value->asA<MaterialX::Color4>(); auto v = d.value->asA<MaterialX::Color4>();
f = v[0] + v[1] + v[2] + v[3]; f = v[0] + v[1] + v[2] + v[3];
break; break;
} }

View File

@ -20,7 +20,7 @@ class GroupNodeParser;
/** /**
* This is base abstraction class for parsing Blender nodes into MaterialX nodes. * This is base abstraction class for parsing Blender nodes into MaterialX nodes.
* NodeParser::compute() should be overrides in child classes. * NodeParser::compute() should be overrided in child classes.
*/ */
class NodeParser { class NodeParser {
protected: protected:

View File

@ -219,7 +219,8 @@ NODE_SHADER_MATERIALX_BEGIN
bool invert = node_->custom2; bool invert = node_->custom2;
NodeItem vector = get_input_value("Vector", NodeItem::Type::Vector3); NodeItem vector = get_input_value("Vector", NodeItem::Type::Vector3);
NodeItem center = get_input_value("Center", NodeItem::Type::Vector3); NodeItem center = get_input_value("Center", NodeItem::Type::Vector3) *
BogdanNagirniak marked this conversation as resolved Outdated

To perform the same result as Blender it requires invert Z.
NodeItem center = get_input_value("Center", NodeItem::Type::Vector3) * val(MaterialX::Vector3(1.0f, 1.0f, -1.0f))

To perform the same result as Blender it requires invert Z. `NodeItem center = get_input_value("Center", NodeItem::Type::Vector3) * val(MaterialX::Vector3(1.0f, 1.0f, -1.0f))`
val(MaterialX::Vector3(1.0f, 1.0f, -1.0f));
vector = vector - center; vector = vector - center;
if (mode == NODE_VECTOR_ROTATE_TYPE_EULER_XYZ) { if (mode == NODE_VECTOR_ROTATE_TYPE_EULER_XYZ) {