26 b.add_input<
decl::Float>(
"Value").default_value(0.5f).min(-10000.0f).max(10000.0f);
27 b.add_input<
decl::Float>(
"Value",
"Value_001").default_value(0.5f).min(-10000.0f).max(10000.0f);
28 b.add_input<
decl::Float>(
"Value",
"Value_002").default_value(0.5f).min(-10000.0f).max(10000.0f);
58 if (item->name !=
nullptr && item->identifier[0] !=
'\0') {
60 (is_geometry_node_tree &&
90 if (
name !=
nullptr) {
94 float min[3] = {0.0f, 0.0f, 0.0f};
95 float max[3] = {1.0f, 1.0f, 1.0f};
114 FloatElem output_elem =
params.get_input_elem<FloatElem>(
"Value");
115 output_elem.merge(
params.get_input_elem<FloatElem>(
"Value_001"));
116 params.set_output_elem(
"Value", output_elem);
143 const StringRef first_input_id =
"Value";
144 const StringRef second_input_id =
"Value_001";
148 params.set_input(first_input_id,
149 params.get_output<
float>(output_id) -
150 params.get_input<
float>(second_input_id));
154 params.set_input(first_input_id,
155 params.get_output<
float>(output_id) +
156 params.get_input<
float>(second_input_id));
160 params.set_input(first_input_id,
162 params.get_input<
float>(second_input_id)));
166 params.set_input(first_input_id,
167 params.get_output<
float>(output_id) *
168 params.get_input<
float>(second_input_id));
181 NodeItem res = empty();
184 NodeItem
x = get_input_value(0, NodeItem::Type::Float);
206 res = (
x + val(0.5f)).
floor();
224 res = val(1.0f) /
x.sqrt();
233 res =
x * val(
float(
M_PI) / 180.0f);
236 res =
x * val(180.0f *
float(
M_1_PI));
248 res =
x.sign() *
x.abs().floor();
253 NodeItem
y = get_input_value(1, NodeItem::Type::Float);
272 res =
x.ln() /
y.ln();
281 res =
x.if_else(NodeItem::CompareOp::Less,
y, val(1.0f), val(0.0f));
284 res =
x.if_else(NodeItem::CompareOp::Greater,
y, val(1.0f), val(0.0f));
296 NodeItem fract_part = (
x -
y) / (
y * val(2.0f));
297 NodeItem if_branch = ((fract_part - fract_part.floor()) *
y * val(2.0f) -
y).abs();
298 res =
y.if_else(NodeItem::CompareOp::NotEq, val(0.0f), if_branch, val(0.0f));
303 NodeItem::CompareOp::NotEq, val(0.0f), (
x - (
x /
y).
floor() *
y), val(0.0f));
308 NodeItem
z = get_input_value(2, NodeItem::Type::Float);
312 NodeItem range = (
y -
z);
313 NodeItem if_branch =
x - (range * ((
x -
z) / range).floor());
314 res = range.if_else(NodeItem::CompareOp::NotEq, val(0.0f), if_branch,
z);
318 res =
z.if_else(NodeItem::CompareOp::Less, (
x -
y).
abs(), val(1.0f), val(0.0f));
325 auto make_smoothmin = [&](NodeItem a, NodeItem
b, NodeItem k) {
326 NodeItem h = (k - (a -
b).abs()).max(val(0.0f)) / k;
327 NodeItem if_branch = a.min(
b) - h * h * h * k * val(1.0f / 6.0f);
328 return k.if_else(NodeItem::CompareOp::NotEq, val(0.0f), if_branch, a.min(
b));
331 res = make_smoothmin(
x,
y,
z);
334 res = -make_smoothmin(-
x, -
y, -
z);
346 bool clamp_output = node_->custom2 != 0;
347 if (clamp_output && res) {
369 ntype.
declare = file_ns::sh_node_math_declare;
371 ntype.
gpu_fn = file_ns::gpu_shader_math;
376 ntype.
eval_elem = file_ns::node_eval_elem;
#define NODE_CLASS_CONVERTER
#define BLI_assert_unreachable()
#define BLT_I18NCONTEXT_ID_NODETREE
#define CTX_IFACE_(context, msgid)
@ NODE_MATH_FLOORED_MODULO
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
bool GPU_link(GPUMaterial *mat, const char *name,...)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
constexpr bool is_empty() const
constexpr const char * c_str() const
void operator()(LinkSearchOpParams ¶ms)
void node_register_type(bNodeType &ntype)
T safe_divide(const T &a, const T &b)
static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_eval_inverse_elem(value_elem::InverseElemEvalParams ¶ms)
static void sh_node_math_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static const char * gpu_shader_get_name(int mode)
static void sh_node_math_declare(NodeDeclarationBuilder &b)
static void node_eval_elem(value_elem::ElemEvalParams ¶ms)
static void node_eval_inverse(inverse_eval::InverseEvalParams ¶ms)
void node_math_build_multi_function(NodeMultiFunctionBuilder &builder)
const FloatMathOperationInfo * get_float_math_operation_info(const int operation)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_math()
void common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_math_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
void node_math_update(bNodeTree *ntree, bNode *node)
const EnumPropertyItem rna_enum_node_math_items[]
NodeInverseElemEvalFunction eval_inverse_elem
NodeMaterialXFunction materialx_fn
NodeInverseEvalFunction eval_inverse
std::string ui_description
void(* labelfunc)(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
NodeGPUExecFunction gpu_fn
NodeElemEvalFunction eval_elem
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void(* updatefunc)(bNodeTree *ntree, bNode *node)
StringRefNull shader_name