MaterialX: Implement export of Input nodes #20

Merged
Bogdan Nagirniak merged 26 commits from Vasyl-Pidhirskyi/blender:BLEN-530 into matx-export-material 2023-09-15 19:55:37 +02:00
Showing only changes of commit 4d97098a4c - Show all commits

View File

@ -77,6 +77,25 @@ static int node_shader_gpu_attribute(GPUMaterial *mat,
return 1;
}
NODE_SHADER_MATERIALX_BEGIN
{
/* TODO: some outputs expected be implemented within the next iteration (see nodedef
* <geompropvalue>) */
NodeItem res = val(MaterialX::Color4(1.0f, 0.0f, 1.0f, 1.0f));
BogdanNagirniak marked this conversation as resolved
Review

Start with NodeItem res = empty(); add check if (STREQ(socket_out_->name, "Color"))

Start with `NodeItem res = empty();` add check `if (STREQ(socket_out_->name, "Color"))`
if (STREQ(socket_out_->name, "Vector")) {
res = val(MaterialX::Vector3(1.0f, 1.0f, 1.0f));
}
if (STREQ(socket_out_->name, "Factor")) {
BogdanNagirniak marked this conversation as resolved Outdated

else if

`else if`
res = res.extract(3);
}
if (STREQ(socket_out_->name, "Alpha")) {
res = res.extract(3);
}
BogdanNagirniak marked this conversation as resolved Outdated

add

else {
BLI_assert_unreachable();
}
add ``` else { BLI_assert_unreachable(); } ```
return res;
}
NODE_SHADER_MATERIALX_END
} // namespace blender::nodes::node_shader_attribute_cc
/* node type definition */
@ -93,6 +112,7 @@ void register_node_type_sh_attribute()
node_type_storage(
&ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage);
ntype.gpu_fn = file_ns::node_shader_gpu_attribute;
ntype.materialx_fn = file_ns::node_shader_materialx;
nodeRegisterType(&ntype);
}