24 b.add_input<
decl::Float>(
"Min").default_value(0.0f).min(-10000.0f).max(10000.0f);
25 b.add_input<
decl::Float>(
"Max").default_value(1.0f).min(-10000.0f).max(10000.0f);
52 static auto minmax_fn = mf::build::SI3_SO<float, float, float, float>(
54 [](
float value,
float min,
float max) {
return std::min(std::max(value,
min), max); });
55 static auto range_fn = mf::build::SI3_SO<float, float, float, float>(
56 "Clamp (Range)", [](
float value,
float a,
float b) {
76 auto type = node_->custom1;
77 NodeItem value = get_input_value(
"Value", NodeItem::Type::Float);
78 NodeItem
min = get_input_value(
"Min", NodeItem::Type::Float);
79 NodeItem max = get_input_value(
"Max", NodeItem::Type::Float);
81 NodeItem res = empty();
84 NodeItem::CompareOp::Less, max, value.clamp(
min, max), value.clamp(max,
min));
87 res = value.clamp(
min, max);
103 ntype.
declare = file_ns::sh_node_clamp_declare;
105 ntype.
initfunc = file_ns::node_shader_init_clamp;
106 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,...)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void set_matching_fn(const mf::MultiFunction *fn)
local_group_size(16, 16) .push_constant(Type b
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 sh_fn_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
NodeMaterialXFunction materialx_fn
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare