26 b.add_input<
decl::Float>(
"Min").default_value(0.0f).min(-10000.0f).max(10000.0f);
27 b.add_input<
decl::Float>(
"Max").default_value(1.0f).min(-10000.0f).max(10000.0f);
54 static auto minmax_fn = mf::build::SI3_SO<float, float, float, float>(
56 [](
float value,
float min,
float max) {
return std::min(std::max(value,
min),
max); });
57 static auto range_fn = mf::build::SI3_SO<float, float, float, float>(
58 "Clamp (Range)", [](
float value,
float a,
float b) {
78 auto type = node_->custom1;
79 NodeItem value = get_input_value(
"Value", NodeItem::Type::Float);
80 NodeItem
min = get_input_value(
"Min", NodeItem::Type::Float);
81 NodeItem
max = get_input_value(
"Max", NodeItem::Type::Float);
83 NodeItem res = empty();
86 NodeItem::CompareOp::Less,
max, value.clamp(
min,
max), value.clamp(
max,
min));
89 res = value.clamp(
min,
max);
106 ntype.
ui_description =
"Clamp a value between a minimum and a maximum";
109 ntype.
declare = file_ns::sh_node_clamp_declare;
111 ntype.
initfunc = file_ns::node_shader_init_clamp;
112 ntype.
gpu_fn = file_ns::gpu_shader_clamp;
#define NODE_CLASS_CONVERTER
MINLINE float clamp_f(float value, float min, float max)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void set_matching_fn(const mf::MultiFunction *fn)
void node_register_type(bNodeType &ntype)
static void sh_node_clamp_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_shader_init_clamp(bNodeTree *, bNode *node)
static void node_shader_buts_clamp(uiLayout *layout, bContext *, PointerRNA *ptr)
static int gpu_shader_clamp(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_clamp_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_clamp()
void common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
NodeMaterialXFunction materialx_fn
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)