forked from blender/blender
MaterialX: add support for Vector nodes #27
@ -83,14 +83,12 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
distance = distance * val(-1.0f);
|
||||
}
|
||||
|
||||
NodeItem height_normal = create_node("heighttonormal", NodeItem::Type::Vector3);
|
||||
height_normal.set_input("in", height);
|
||||
height_normal.set_input("scale", strength);
|
||||
NodeItem height_normal = create_node(
|
||||
"heighttonormal", NodeItem::Type::Vector3, {{"in", height}, {"scale", strength}});
|
||||
|
||||
NodeItem res = create_node("normalmap", NodeItem::Type::Vector3);
|
||||
res.set_input("in", height_normal);
|
||||
res.set_input("scale", distance);
|
||||
res.set_input("normal", normal);
|
||||
NodeItem res = create_node("normalmap",
|
||||
NodeItem::Type::Vector3,
|
||||
{{"in", height_normal}, {"scale", distance}, {"normal", normal}});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
NodeItem height = get_input_value("Height", NodeItem::Type::Float) - midlevel;
|
||||
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
|
||||
|
||||
NodeItem res = create_node("displacement", NodeItem::Type::Displacementshader);
|
||||
res.set_input("displacement", height);
|
||||
res.set_input("scale", scale);
|
||||
NodeItem res = create_node("displacement",
|
||||
NodeItem::Type::Displacementshader,
|
||||
{{"displacement", height}, {"scale", scale}});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -77,32 +77,33 @@ static void node_shader_update_mapping(bNodeTree *ntree, bNode *node)
|
||||
NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
NodeItem res = create_node("rotate3d", NodeItem::Type::Vector3);
|
||||
NodeItem res = empty();
|
||||
NodeItem location = get_input_value("Location", NodeItem::Type::Vector3);
|
||||
NodeItem scale = get_input_value("Scale", 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);
|
||||
MaterialX::Vector3 axis_vector;
|
||||
NodeItem in = empty();
|
||||
const int mode = node_->custom1;
|
||||
|
||||
switch (mode) {
|
||||
case NODE_MAPPING_TYPE_POINT:
|
||||
in = vector * scale;
|
||||
res = vector * scale;
|
||||
break;
|
||||
|
||||
case NODE_MAPPING_TYPE_TEXTURE:
|
||||
in = vector - location;
|
||||
res = vector - location;
|
||||
break;
|
||||
|
||||
case NODE_MAPPING_TYPE_VECTOR:
|
||||
in = vector * scale;
|
||||
res = vector * scale;
|
||||
break;
|
||||
|
||||
case NODE_MAPPING_TYPE_NORMAL:
|
||||
in = vector / scale;
|
||||
res = vector / scale;
|
||||
break;
|
||||
BLI_assert_unreachable();
|
||||
return vector;
|
||||
}
|
||||
|
||||
bool tex = mode == NODE_MAPPING_TYPE_TEXTURE;
|
||||
@ -114,12 +115,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
inv *= -1.0f;
|
||||
}
|
||||
axis_vector[i] = inv;
|
||||
NodeItem res_rot = create_node("rotate3d", NodeItem::Type::Vector3);
|
||||
res_rot.set_input("in", in);
|
||||
res_rot.set_input("amount", angle.extract(i));
|
||||
res_rot.set_input("axis", val(axis_vector));
|
||||
in = res_rot;
|
||||
res = in;
|
||||
res = create_node("rotate3d",
|
||||
NodeItem::Type::Vector3,
|
||||
{{"in", res}, {"amount", angle.extract(i)}, {"axis", val(axis_vector)}});
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
@ -132,9 +130,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
break;
|
||||
|
||||
case NODE_MAPPING_TYPE_NORMAL:
|
||||
NodeItem normalize = create_node("normalize", NodeItem::Type::Vector3);
|
||||
normalize.set_input("in", res);
|
||||
res = normalize;
|
||||
res = create_node("normalize", NodeItem::Type::Vector3, {{"in", res}});
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
|
@ -42,9 +42,7 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
NodeItem in1 = get_output_default("Normal", NodeItem::Type::Vector3);
|
||||
NodeItem in2 = get_input_value("Normal", NodeItem::Type::Vector3);
|
||||
if (name == "Dot") {
|
||||
NodeItem res = create_node("dotproduct", NodeItem::Type::Float);
|
||||
res.set_input("in1", in1);
|
||||
res.set_input("in2", in2);
|
||||
NodeItem res = create_node("dotproduct", NodeItem::Type::Float, {{"in1", in1}, {"in2", in2}});
|
||||
return res;
|
||||
}
|
||||
return in1;
|
||||
|
@ -49,9 +49,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
NodeItem vector = get_input_link("Vector", NodeItem::Type::Vector3);
|
||||
NodeItem scale = get_input_value("Scale", NodeItem::Type::Float);
|
||||
|
||||
NodeItem res = create_node("displacement", NodeItem::Type::Displacementshader);
|
||||
res.set_input("displacement", vector);
|
||||
res.set_input("scale", scale);
|
||||
NodeItem res = create_node("displacement",
|
||||
NodeItem::Type::Displacementshader,
|
||||
{{"displacement", vector}, {"scale", scale}});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -241,10 +241,10 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
inv *= -1.0f;
|
||||
}
|
||||
axis_vector[i] = inv;
|
||||
NodeItem res_rot = create_node("rotate3d", NodeItem::Type::Vector3);
|
||||
res_rot.set_input("in", vector);
|
||||
res_rot.set_input("amount", angle.extract(i));
|
||||
res_rot.set_input("axis", val(axis_vector));
|
||||
NodeItem res_rot = create_node(
|
||||
"rotate3d",
|
||||
NodeItem::Type::Vector3,
|
||||
{{"in", vector}, {"amount", angle.extract(i)}, {"axis", val(axis_vector)}});
|
||||
vector = res_rot;
|
||||
}
|
||||
res = vector;
|
||||
@ -274,6 +274,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
case NODE_VECTOR_ROTATE_TYPE_AXIS_Z:
|
||||
axis = val(MaterialX::Vector3(0.0f, 0.0f, -1.0f));
|
||||
break;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return vector;
|
||||
}
|
||||
res.set_input("in", vector);
|
||||
res.set_input("amount", angle);
|
||||
|
@ -156,6 +156,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
break;
|
||||
case SHD_VECT_TRANSFORM_SPACE_CAMERA:
|
||||
return vector;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return vector;
|
||||
}
|
||||
switch (nodeprop->convert_to) {
|
||||
case SHD_VECT_TRANSFORM_SPACE_WORLD:
|
||||
@ -166,6 +169,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
break;
|
||||
case SHD_VECT_TRANSFORM_SPACE_CAMERA:
|
||||
return vector;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return vector;
|
||||
}
|
||||
if (fromspace == tospace) {
|
||||
return vector;
|
||||
@ -181,6 +187,9 @@ NODE_SHADER_MATERIALX_BEGIN
|
||||
case SHD_VECT_TRANSFORM_TYPE_VECTOR:
|
||||
res = create_node("transformvector", NodeItem::Type::Vector3);
|
||||
break;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return vector;
|
||||
}
|
||||
res.set_input("in", vector);
|
||||
res.set_input("fromspace", val(fromspace));
|
||||
|
Loading…
Reference in New Issue
Block a user