MaterialX: Implement White Noise node #113495
|
@ -185,6 +185,45 @@ static void sh_node_noise_build_multi_function(NodeMultiFunctionBuilder &builder
|
|||
builder.construct_and_set_matching_fn<WhiteNoiseFunction>(int(node.custom1));
|
||||
}
|
||||
|
||||
NODE_SHADER_MATERIALX_BEGIN
|
||||
#ifdef WITH_MATERIALX
|
||||
{
|
||||
NodeItem noise = empty();
|
||||
NodeItem vector = get_input_link("Vector", NodeItem::Type::Vector3);
|
||||
NodeItem w = get_input_value("W", NodeItem::Type::Float);
|
||||
switch (node_->custom1) {
|
||||
DagerD marked this conversation as resolved
Outdated
|
||||
case 1:
|
||||
DagerD marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
Are there existing constants? Are there existing constants?
|
||||
noise = create_node("cellnoise2d",
|
||||
NodeItem::Type::Float,
|
||||
DagerD marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
Optimize getting values, only w is used here Optimize getting values, only w is used here
|
||||
{{"texcoord", w.convert(NodeItem::Type::Vector2)}});
|
||||
break;
|
||||
case 2:
|
||||
noise = create_node("cellnoise2d",
|
||||
NodeItem::Type::Float,
|
||||
{{"texcoord", vector.convert(NodeItem::Type::Vector2)}});
|
||||
break;
|
||||
case 3:
|
||||
noise = create_node("cellnoise3d", NodeItem::Type::Float, {{"position", vector}});
|
||||
break;
|
||||
case 4:
|
||||
noise = create_node("cellnoise3d", NodeItem::Type::Float, {{"position", vector + w}});
|
||||
break;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
break;
|
||||
}
|
||||
|
||||
if (STREQ(socket_out_->name, "Value")) {
|
||||
return noise;
|
||||
}
|
||||
|
||||
NodeItem combine = create_node(
|
||||
"combine3", NodeItem::Type::Color3, {{"in1", noise}, {"in2", val(1.0f)}, {"in3", val(0.5f)}});
|
||||
DagerD marked this conversation as resolved
Outdated
Bogdan Nagirniak
commented
Add comment what we are doing here Add comment what we are doing here
|
||||
return create_node("hsvtorgb", NodeItem::Type::Color3, {{"in", combine}});
|
||||
}
|
||||
#endif
|
||||
NODE_SHADER_MATERIALX_END
|
||||
|
||||
} // namespace blender::nodes::node_shader_tex_white_noise_cc
|
||||
|
||||
void register_node_type_sh_tex_white_noise()
|
||||
|
@ -200,6 +239,7 @@ void register_node_type_sh_tex_white_noise()
|
|||
ntype.gpu_fn = file_ns::gpu_shader_tex_white_noise;
|
||||
ntype.updatefunc = file_ns::node_shader_update_tex_white_noise;
|
||||
ntype.build_multi_function = file_ns::sh_node_noise_build_multi_function;
|
||||
ntype.materialx_fn = file_ns::node_shader_materialx;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Add variable which name this node option:
int <option name> = node_->custom1
.See example https://projects.blender.org/blender/blender/src/branch/main/source/blender/nodes/shader/nodes/node_shader_math.cc#L186