Blender V5.3
node_shader_mix.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10
11#include "BKE_material.hh"
12
14#include "BLI_math_vector_c.hh"
15#include "BLI_string_utf8.hh"
16
17#include "DNA_material_types.h"
18
20#include "UI_resources.hh"
21
22#include "node_shader_util.hh"
23#include "node_util.hh"
24
26
27#include "NOD_multi_function.hh"
29
30#include "RNA_access.hh"
31#include "RNA_enum_types.hh"
32
33namespace blender {
34
36
38
40{
41 b.is_function_node();
42 /* WARNING:
43 * Input socket indices must be kept in sync with ntree_shader_disconnect_inactive_mix_branches
44 */
45 b.add_input<decl::Float>("Factor"_ustr, "Factor_Float"_ustr)
46 .default_value(1.0f)
47 .min(0.0f)
48 .max(1.0f)
49 .subtype(PROP_FACTOR)
50 .no_muted_links()
51 .description("Amount of mixing between the A and B inputs")
52 .compositor_domain_priority(2);
53 b.add_input<decl::Vector>("Factor"_ustr, "Factor_Vector"_ustr)
54 .default_value(float3(0.5f))
55 .min(0.0f)
56 .max(1.0f)
57 .subtype(PROP_FACTOR)
58 .no_muted_links()
59 .description("Amount of mixing between the A and B vector inputs")
60 .compositor_domain_priority(2);
61
62 b.add_input<decl::Float>("A"_ustr, "A_Float"_ustr)
63 .min(-10000.0f)
64 .max(10000.0f)
65 .is_default_link_socket()
66 .translation_context(BLT_I18NCONTEXT_ID_NODETREE)
67 .description("Value of the first floating number input")
68 .compositor_domain_priority(0);
69 b.add_input<decl::Float>("B"_ustr, "B_Float"_ustr)
70 .min(-10000.0f)
71 .max(10000.0f)
72 .translation_context(BLT_I18NCONTEXT_ID_NODETREE)
73 .description("Value of the second floating number input")
74 .compositor_domain_priority(1);
75
76 b.add_input<decl::Vector>("A"_ustr, "A_Vector"_ustr)
78 .translation_context(BLT_I18NCONTEXT_ID_NODETREE)
79 .description("Value of the first vector input")
80 .compositor_domain_priority(0);
81 b.add_input<decl::Vector>("B"_ustr, "B_Vector"_ustr)
83 .description("Value of the second vector input")
84 .compositor_domain_priority(1);
85
86 b.add_input<decl::Color>("A"_ustr, "A_Color"_ustr)
87 .default_value({0.5f, 0.5f, 0.5f, 1.0f})
88 .is_default_link_socket()
89 .translation_context(BLT_I18NCONTEXT_ID_NODETREE)
90 .description("Value of the first color input")
91 .compositor_domain_priority(0);
92 b.add_input<decl::Color>("B"_ustr, "B_Color"_ustr)
93 .default_value({0.5f, 0.5f, 0.5f, 1.0f})
94 .translation_context(BLT_I18NCONTEXT_ID_NODETREE)
95 .description("Value of the second color input")
96 .compositor_domain_priority(1);
97
98 b.add_input<decl::Rotation>("A"_ustr, "A_Rotation"_ustr)
100 .translation_context(BLT_I18NCONTEXT_ID_NODETREE)
101 .compositor_domain_priority(0);
102 b.add_input<decl::Rotation>("B"_ustr, "B_Rotation"_ustr)
104 .compositor_domain_priority(1);
105
106 b.add_output<decl::Float>("Result"_ustr, "Result_Float"_ustr);
107 b.add_output<decl::Vector>("Result"_ustr, "Result_Vector"_ustr);
108 b.add_output<decl::Color>("Result"_ustr, "Result_Color"_ustr);
109 b.add_output<decl::Rotation>("Result"_ustr, "Result_Rotation"_ustr);
110};
111
112static void sh_node_mix_layout(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
113{
114 const NodeShaderMix &data = node_storage(*static_cast<const bNode *>(ptr->data));
115 layout.prop(ptr, "data_type", UI_ITEM_NONE, "", ICON_NONE);
116 switch (data.data_type) {
117 case SOCK_FLOAT:
118 break;
119 case SOCK_VECTOR:
120 layout.prop(ptr, "factor_mode", UI_ITEM_NONE, "", ICON_NONE);
121 break;
122 case SOCK_RGBA:
123 layout.prop(ptr, "blend_type", UI_ITEM_NONE, "", ICON_NONE);
124 layout.prop(ptr, "clamp_result", UI_ITEM_NONE, std::nullopt, ICON_NONE);
125 break;
126 case SOCK_ROTATION:
127 break;
128 default:
130 }
131 layout.prop(ptr, "clamp_factor", UI_ITEM_NONE, std::nullopt, ICON_NONE);
132}
133
134static void sh_node_mix_label(const bNodeTree * /*ntree*/,
135 const bNode *node,
136 char *label,
137 int label_maxncpy)
138{
139 const NodeShaderMix &storage = node_storage(*node);
140 if (storage.data_type == SOCK_RGBA) {
141 const char *name;
142 bool enum_label = RNA_enum_name(rna_enum_ramp_blend_items, storage.blend_type, &name);
143 if (!enum_label) {
144 name = CTX_N_(BLT_I18NCONTEXT_COLOR, "Unknown");
145 }
146 BLI_strncpy_utf8(label, CTX_IFACE_(BLT_I18NCONTEXT_COLOR, name), label_maxncpy);
147 return;
148 }
149 BLI_strncpy_utf8(label, IFACE_("Mix"), label_maxncpy);
150}
151
153{
154 const NodeShaderMix &storage = node_storage(*node);
155 const eNodeSocketDatatype data_type = storage.data_type;
156
157 switch (data_type) {
158 case SOCK_VECTOR:
160 case SOCK_RGBA:
161 return NODE_CLASS_OP_COLOR;
162 default:
164 }
165}
166
168{
169 const NodeShaderMix &storage = node_storage(*node);
170 const eNodeSocketDatatype data_type = storage.data_type;
171
172 bNodeSocket *sock_factor = node->inputs.first();
173 bNodeSocket *sock_factor_vec = static_cast<bNodeSocket *>(sock_factor->next);
174
175 bool use_vector_factor = data_type == SOCK_VECTOR &&
176 storage.factor_mode != NODE_MIX_MODE_UNIFORM;
177
178 bke::node_set_socket_availability(*ntree, *sock_factor, !use_vector_factor);
179
180 bke::node_set_socket_availability(*ntree, *sock_factor_vec, use_vector_factor);
181
182 for (bNodeSocket *socket = sock_factor_vec->next; socket != nullptr; socket = socket->next) {
183 bke::node_set_socket_availability(*ntree, *socket, socket->type == data_type);
184 }
185
186 for (bNodeSocket &socket : node->outputs) {
187 bke::node_set_socket_availability(*ntree, socket, socket.type == data_type);
188 }
189}
190
192 public:
196 {
197 bNode &node = params.add_node("ShaderNodeMix"_ustr);
198 node_storage(node).data_type = SOCK_RGBA;
199 node_storage(node).blend_type = type;
201 }
202};
203
205{
207 switch (params.other_socket().type) {
208 case SOCK_BOOLEAN:
209 case SOCK_INT:
210 case SOCK_FLOAT:
211 type = SOCK_FLOAT;
212 break;
213 case SOCK_VECTOR:
214 type = SOCK_VECTOR;
215 break;
216 case SOCK_RGBA:
217 type = SOCK_RGBA;
218 break;
219 case SOCK_ROTATION:
220 type = SOCK_ROTATION;
221 break;
222 default:
223 return;
224 }
225
226 /* Ensure color math operations have higher priority than vector or float math operations. */
227 int weight = type == SOCK_RGBA ? 4 : 0;
228 if (params.in_out() == SOCK_OUT) {
229 params.add_item(IFACE_("Result"), [type](LinkSearchOpParams &params) {
230 bNode &node = params.add_node("ShaderNodeMix"_ustr);
231 node_storage(node).data_type = type;
232 params.update_and_connect_available_socket(node, "Result"_ustr);
233 });
234 }
235 else {
236 params.add_item(
238 [type](LinkSearchOpParams &params) {
239 bNode &node = params.add_node("ShaderNodeMix"_ustr);
240 node_storage(node).data_type = type;
242 },
243 weight);
244 weight--;
245 params.add_item(
247 [type](LinkSearchOpParams &params) {
248 bNode &node = params.add_node("ShaderNodeMix"_ustr);
249 node_storage(node).data_type = type;
251 },
252 weight);
253 weight--;
254 if (ELEM(type, SOCK_VECTOR, SOCK_RGBA)) {
255 params.add_item(
256 IFACE_("Factor (Non-Uniform)"),
257 [](LinkSearchOpParams &params) {
258 bNode &node = params.add_node("ShaderNodeMix"_ustr);
259 node_storage(node).data_type = SOCK_VECTOR;
260 node_storage(node).factor_mode = NODE_MIX_MODE_NON_UNIFORM;
261 params.update_and_connect_available_socket(node, "Factor"_ustr);
262 },
263 weight);
264 weight--;
265 }
266 if (type != SOCK_ROTATION) {
267 params.add_item(
268 IFACE_("Factor"),
269 [type](LinkSearchOpParams &params) {
270 bNode &node = params.add_node("ShaderNodeMix"_ustr);
271 node_storage(node).data_type = type;
272 params.update_and_connect_available_socket(node, "Factor"_ustr);
273 },
274 weight);
275 weight--;
276 }
277 }
278
279 if (type == SOCK_ROTATION) {
280 return;
281 }
282
283 if (type != SOCK_RGBA) {
284 weight--;
285 }
286 const UString socket_name = params.in_out() == SOCK_IN ? "A"_ustr : "Result"_ustr;
287 for (const EnumPropertyItem *item = rna_enum_ramp_blend_items; item->identifier != nullptr;
288 item++)
289 {
290 if (item->name != nullptr && item->identifier[0] != '\0') {
291 params.add_item(IFACE_(item->name), SocketSearchOp{socket_name, item->value}, weight);
292 }
293 }
294}
295
296static void node_mix_init(bNodeTree * /*tree*/, bNode *node)
297{
298 NodeShaderMix *data = MEM_new<NodeShaderMix>(__func__);
299 data->data_type = SOCK_FLOAT;
300 data->factor_mode = NODE_MIX_MODE_UNIFORM;
301 data->clamp_factor = 1;
302 data->clamp_result = 0;
303 data->blend_type = MA_RAMP_BLEND;
304 node->storage = data;
305}
306
307static const char *gpu_shader_get_name(eNodeSocketDatatype data_type,
308 const bool non_uniform,
309 const int blend_type)
310{
311 switch (data_type) {
312 case SOCK_FLOAT:
313 return "node_mix_float";
314 case SOCK_VECTOR:
315 return (non_uniform) ? "node_mix_vector_non_uniform" : "node_mix_vector";
316 case SOCK_RGBA:
317 switch (blend_type) {
318 case MA_RAMP_BLEND:
319 return "node_mix_blend";
320 case MA_RAMP_ADD:
321 return "node_mix_add";
322 case MA_RAMP_MULT:
323 return "node_mix_mult";
324 case MA_RAMP_SUB:
325 return "node_mix_sub";
326 case MA_RAMP_SCREEN:
327 return "node_mix_screen";
328 case MA_RAMP_DIV:
329 return "node_mix_div_fallback";
330 case MA_RAMP_DIFF:
331 return "node_mix_diff";
333 return "node_mix_exclusion";
334 case MA_RAMP_DARK:
335 return "node_mix_dark";
336 case MA_RAMP_LIGHT:
337 return "node_mix_light";
338 case MA_RAMP_OVERLAY:
339 return "node_mix_overlay";
340 case MA_RAMP_DODGE:
341 return "node_mix_dodge";
342 case MA_RAMP_BURN:
343 return "node_mix_burn";
344 case MA_RAMP_HUE:
345 return "node_mix_hue";
346 case MA_RAMP_SAT:
347 return "node_mix_sat";
348 case MA_RAMP_VAL:
349 return "node_mix_val";
350 case MA_RAMP_COLOR:
351 return "node_mix_color";
352 case MA_RAMP_SOFT:
353 return "node_mix_soft";
354 case MA_RAMP_LINEAR:
355 return "node_mix_linear";
356 default:
358 return nullptr;
359 }
360 case SOCK_ROTATION:
361 return "node_mix_rotation";
362 default:
364 return nullptr;
365 }
366}
367
369 bNode *node,
370 bNodeExecData * /*execdata*/,
373{
374 const NodeShaderMix &storage = node_storage(*node);
375 const bool is_non_uniform = storage.factor_mode == NODE_MIX_MODE_NON_UNIFORM;
376 const bool is_color_mode = storage.data_type == SOCK_RGBA;
377 const bool is_vector_mode = storage.data_type == SOCK_VECTOR;
378 const int blend_type = storage.blend_type;
379 const char *name = gpu_shader_get_name(storage.data_type, is_non_uniform, blend_type);
380
381 if (name == nullptr) {
382 return 0;
383 }
384
385 if (storage.clamp_factor) {
386 if (is_non_uniform && is_vector_mode) {
387 const float min[3] = {0.0f, 0.0f, 0.0f};
388 const float max[3] = {1.0f, 1.0f, 1.0f};
389 const GPUNodeLink *factor_link = in[1].link ? in[1].link : GPU_uniform(in[1]);
390 GPU_link(mat,
391 "node_mix_clamp_vector",
392 factor_link,
395 &in[1].link);
396 }
397 else {
398 const float min = 0.0f;
399 const float max = 1.0f;
400 const GPUNodeLink *factor_link = in[0].link ? in[0].link : GPU_uniform(in[0]);
401 GPU_link(mat,
402 "node_mix_clamp_value",
403 factor_link,
406 &in[0].link);
407 }
408 }
409
410 /* Avoid GPU_stack_link here because it creates uniforms for unavailable sockets. */
411 int ret = 0;
412 switch (storage.data_type) {
413 case SOCK_FLOAT:
414 ret = GPU_link(mat,
415 name,
416 GPU_node_get_input_link(*node, in, "Factor_Float"),
417 GPU_node_get_input_link(*node, in, "A_Float"),
418 GPU_node_get_input_link(*node, in, "B_Float"),
419 &GPU_node_get_output(*node, out, "Result_Float").link);
420 break;
421 case SOCK_VECTOR:
422 if (is_non_uniform) {
423 ret = GPU_link(mat,
424 name,
425 GPU_node_get_input_link(*node, in, "Factor_Vector"),
426 GPU_node_get_input_link(*node, in, "A_Vector"),
427 GPU_node_get_input_link(*node, in, "B_Vector"),
428 &GPU_node_get_output(*node, out, "Result_Vector").link);
429 }
430 else {
431 ret = GPU_link(mat,
432 name,
433 GPU_node_get_input_link(*node, in, "Factor_Float"),
434 GPU_node_get_input_link(*node, in, "A_Vector"),
435 GPU_node_get_input_link(*node, in, "B_Vector"),
436 &GPU_node_get_output(*node, out, "Result_Vector").link);
437 }
438 break;
439 case SOCK_RGBA:
440 ret = GPU_link(mat,
441 name,
442 GPU_node_get_input_link(*node, in, "Factor_Float"),
443 GPU_node_get_input_link(*node, in, "A_Color"),
444 GPU_node_get_input_link(*node, in, "B_Color"),
445 &GPU_node_get_output(*node, out, "Result_Color").link);
446 break;
447 case SOCK_ROTATION:
448 ret = GPU_link(mat,
449 name,
450 GPU_node_get_input_link(*node, in, "Factor_Float"),
451 GPU_node_get_input_link(*node, in, "A_Rotation"),
452 GPU_node_get_input_link(*node, in, "B_Rotation"),
453 &GPU_node_get_output(*node, out, "Result_Rotation").link);
454 break;
455 default:
457 return 0;
458 }
459
460 if (ret && is_color_mode && storage.clamp_result) {
461 const float min[4] = {0.0f, 0.0f, 0.0f, 0.0f};
462 const float max[4] = {1.0f, 1.0f, 1.0f, 1.0f};
463 GPUNodeStack &result = GPU_node_get_output(*node, out, "Result_Color");
464 GPU_link(mat,
465 "node_mix_clamp_color",
466 result.link,
469 &result.link);
470 }
471 return ret;
472}
473
474class MixColorFunction : public mf::MultiFunction {
475 private:
476 const bool clamp_factor_;
477 const bool clamp_result_;
478 const int blend_type_;
479
480 public:
481 MixColorFunction(const bool clamp_factor, const bool clamp_result, const int blend_type)
482 : clamp_factor_(clamp_factor), clamp_result_(clamp_result), blend_type_(blend_type)
483 {
484 static const mf::Signature signature = []() {
485 mf::Signature signature;
486 mf::SignatureBuilder builder{"MixColor", signature};
487 builder.single_input<float>("Factor");
488 builder.single_input<ColorGeometry4f>("A");
489 builder.single_input<ColorGeometry4f>("B");
490 builder.single_output<ColorGeometry4f>("Result");
491 return signature;
492 }();
493 this->set_signature(&signature);
494 }
495
496 void call(const IndexMask &mask, mf::Params params, mf::Context /*context*/) const override
497 {
498 const VArray<float> &fac = params.readonly_single_input<float>(0, "Factor");
499 const VArray<ColorGeometry4f> &col1 = params.readonly_single_input<ColorGeometry4f>(1, "A");
500 const VArray<ColorGeometry4f> &col2 = params.readonly_single_input<ColorGeometry4f>(2, "B");
501 MutableSpan<ColorGeometry4f> results = params.uninitialized_single_output<ColorGeometry4f>(
502 3, "Result");
503
504 if (clamp_factor_) {
505 mask.foreach_index_optimized<int64_t>([&](const int64_t i) {
506 results[i] = col1[i];
507 ramp_blend(blend_type_, results[i], std::clamp(fac[i], 0.0f, 1.0f), col2[i]);
508 });
509 }
510 else {
511 mask.foreach_index_optimized<int64_t>([&](const int64_t i) {
512 results[i] = col1[i];
513 ramp_blend(blend_type_, results[i], fac[i], col2[i]);
514 });
515 }
516
517 if (clamp_result_) {
518 mask.foreach_index_optimized<int64_t>(
519 [&](const int64_t i) { clamp_v4(results[i], 0.0f, 1.0f); });
520 }
521 }
522
523 void hash_unique(UniqueHashBytes &hash) const override
524 {
525 static constexpr int8_t id = 0;
526 hash.add(&id);
527 hash.add(clamp_factor_);
528 hash.add(clamp_result_);
529 hash.add(blend_type_);
530 }
531};
532
533static const mf::MultiFunction *get_multi_function(const bNode &node)
534{
535 const NodeShaderMix *data = static_cast<NodeShaderMix *>(node.storage);
536 bool uniform_factor = data->factor_mode == NODE_MIX_MODE_UNIFORM;
537 const bool clamp_factor = data->clamp_factor;
538 switch (data->data_type) {
539 case SOCK_FLOAT: {
540 if (clamp_factor) {
541 static auto fn = mf::build::SI3_SO<float, float, float, float>(
542 "Clamp Mix Float", [](float t, const float a, const float b) {
543 return math::interpolate(a, b, std::clamp(t, 0.0f, 1.0f));
544 });
545 return &fn;
546 }
547 static auto fn = mf::build::SI3_SO<float, float, float, float>(
548 "Mix Float",
549 [](const float t, const float a, const float b) { return math::interpolate(a, b, t); });
550 return &fn;
551 }
552 case SOCK_VECTOR: {
553 if (clamp_factor) {
554 if (uniform_factor) {
555 static auto fn = mf::build::SI3_SO<float, float3, float3, float3>(
556 "Clamp Mix Vector", [](const float t, const float3 a, const float3 b) {
557 return math::interpolate(a, b, std::clamp(t, 0.0f, 1.0f));
558 });
559 return &fn;
560 }
561 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
562 "Clamp Mix Vector Non Uniform", [](float3 t, const float3 a, const float3 b) {
563 t = math::clamp(t, 0.0f, 1.0f);
564 return a * (float3(1.0f) - t) + b * t;
565 });
566 return &fn;
567 }
568 if (uniform_factor) {
569 static auto fn = mf::build::SI3_SO<float, float3, float3, float3>(
570 "Mix Vector", [](const float t, const float3 a, const float3 b) {
571 return math::interpolate(a, b, t);
572 });
573 return &fn;
574 }
575 static auto fn = mf::build::SI3_SO<float3, float3, float3, float3>(
576 "Mix Vector Non Uniform", [](const float3 t, const float3 a, const float3 b) {
577 return a * (float3(1.0f) - t) + b * t;
578 });
579 return &fn;
580 }
581 case SOCK_ROTATION: {
582 if (clamp_factor) {
583 static auto fn =
584 mf::build::SI3_SO<float, math::Quaternion, math::Quaternion, math::Quaternion>(
585 "Clamp Mix Rotation",
586 [](const float t, const math::Quaternion &a, const math::Quaternion &b) {
587 return math::interpolate(a, b, math::clamp(t, 0.0f, 1.0f));
588 });
589 return &fn;
590 }
591 static auto fn =
592 mf::build::SI3_SO<float, math::Quaternion, math::Quaternion, math::Quaternion>(
593 "Mix Rotation",
594 [](const float t, const math::Quaternion &a, const math::Quaternion &b) {
595 return math::interpolate(a, b, t);
596 });
597 return &fn;
598 }
599 default: {
601 return nullptr;
602 }
603 }
604}
605
607{
608 const NodeShaderMix &storage = node_storage(builder.node());
609
610 if (storage.data_type == SOCK_RGBA) {
612 storage.clamp_factor, storage.clamp_result, storage.blend_type);
613 }
614 else {
615 const mf::MultiFunction *fn = get_multi_function(builder.node());
616 builder.set_matching_fn(fn);
617 }
618}
619
621#ifdef WITH_MATERIALX
622{
623 const NodeShaderMix *data = (NodeShaderMix *)node_->storage;
624
625 NodeItem factor = empty();
626 NodeItem value1 = empty();
627 NodeItem value2 = empty();
628 switch (data->data_type) {
629 case SOCK_FLOAT:
630 factor = get_input_value(0, NodeItem::Type::Float);
631 value1 = get_input_value(2, NodeItem::Type::Float);
632 value2 = get_input_value(3, NodeItem::Type::Float);
633 break;
634
635 case SOCK_VECTOR:
636 if (data->factor_mode == NODE_MIX_MODE_UNIFORM) {
637 factor = get_input_value(0, NodeItem::Type::Float);
638 }
639 else {
640 factor = get_input_value(1, NodeItem::Type::Vector3);
641 }
642 value1 = get_input_value(4, NodeItem::Type::Vector3);
643 value2 = get_input_value(5, NodeItem::Type::Vector3);
644 break;
645
646 case SOCK_RGBA:
647 factor = get_input_value(0, NodeItem::Type::Float);
648 value1 = get_input_value(6, NodeItem::Type::Color3);
649 value2 = get_input_value(7, NodeItem::Type::Color3);
650 break;
651
652 default:
654 }
655
656 if (data->clamp_factor) {
657 factor = factor.clamp();
658 }
659 NodeItem res = factor.mix(value1, value2);
660 if (data->data_type == SOCK_RGBA) {
661 /* TODO: Apply data->blend_type */
662
663 if (data->clamp_result) {
664 res = res.clamp();
665 }
666 }
667 return res;
668}
669#endif
671
672} // namespace nodes::node_sh_mix_cc
673
675{
676 namespace file_ns = nodes::node_sh_mix_cc;
677
678 static bke::bNodeType ntype;
679 common_node_type_base(&ntype, "ShaderNodeMix"_ustr, SH_NODE_MIX);
680 ntype.ui_name = "Mix";
681 ntype.ui_description = "Mix values by a factor";
682 ntype.enum_name_legacy = "MIX";
684 ntype.declare = file_ns::sh_node_mix_declare;
685 ntype.ui_class = file_ns::sh_node_mix_ui_class;
686 ntype.gpu_fn = file_ns::gpu_shader_mix;
687 ntype.updatefunc = file_ns::sh_node_mix_update;
688 ntype.initfunc = file_ns::node_mix_init;
691 ntype.build_multi_function = file_ns::sh_node_mix_build_multi_function;
692 ntype.draw_buttons = file_ns::sh_node_mix_layout;
693 ntype.labelfunc = file_ns::sh_node_mix_label;
694 ntype.gather_link_search_ops = file_ns::node_mix_gather_link_searches;
695 ntype.materialx_fn = file_ns::node_shader_materialx;
696
698}
699
700} // namespace blender
General operations, lookup, etc. for materials.
#define NODE_CLASS_CONVERTER
Definition BKE_node.hh:484
#define NODE_STORAGE_FUNCS(StorageT)
Definition BKE_node.hh:1353
#define NODE_CLASS_OP_VECTOR
Definition BKE_node.hh:481
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:480
#define SH_NODE_MIX
#define CTX_N_(context, msgid)
#define BLT_I18NCONTEXT_ID_NODETREE
#define CTX_IFACE_(context, msgid)
#define IFACE_(msgid)
#define BLT_I18NCONTEXT_COLOR
#define UI_ITEM_NONE
#define BLI_assert_unreachable()
#define ELEM(...)
btScalar max
void set_signature(const Signature *signature)
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
void update_and_connect_available_socket(bNode &new_node, UString socket_name)
void set_matching_fn(const mf::MultiFunction *fn)
std::optional< std::string > translation_context
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
void hash_unique(UniqueHashBytes &hash) const override
MixColorFunction(const bool clamp_factor, const bool clamp_result, const int blend_type)
void operator()(LinkSearchOpParams &params)
#define storage(slot, qualifiers)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_set_socket_availability(bNodeTree &ntree, bNodeSocket &sock, bool is_available)
Definition node.cc:5499
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:6166
QuaternionBase< float > Quaternion
T clamp(const T &a, const T &min, const T &max)
T interpolate(const T &a, const T &b, const FactorT &t)
static const char * gpu_shader_get_name(eNodeSocketDatatype data_type, const bool non_uniform, const int blend_type)
static void node_mix_init(bNodeTree *, bNode *node)
static int sh_node_mix_ui_class(const bNode *node)
static void node_mix_gather_link_searches(GatherLinkSearchOpParams &params)
static void sh_node_mix_build_multi_function(NodeMultiFunctionBuilder &builder)
static const mf::MultiFunction * get_multi_function(const bNode &node)
static int gpu_shader_mix(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void sh_node_mix_declare(NodeDeclarationBuilder &b)
static void sh_node_mix_update(bNodeTree *ntree, bNode *node)
static void sh_node_mix_label(const bNodeTree *, const bNode *node, char *label, int label_maxncpy)
static void sh_node_mix_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
BMesh Iterators.
__int64 int64_t
Definition BKE_text.h:90
void ramp_blend(int type, float r_col[4], float fac, const float col[4])
const EnumPropertyItem rna_enum_ramp_blend_items[]
GPUNodeLink * GPU_node_get_input_link(const bNode &node, GPUNodeStack inputs[], StringRef identifier)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
GPUNodeLink * GPU_uniform(const float *num)
GPUNodeLink * GPU_constant(const float *num)
bool GPU_link(GPUMaterial *mat, const char *name,...)
BMesh const char void * data
bool RNA_enum_name(const EnumPropertyItem *item, const int value, const char **r_name)
GPUNodeStack & GPU_node_get_output(const bNode &node, GPUNodeStack outputs[], StringRef identifier)
MINLINE void clamp_v4(float vec[4], float min, float max)
void register_node_type_sh_mix()
@ NODE_MIX_MODE_NON_UNIFORM
@ NODE_MIX_MODE_UNIFORM
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:57
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
void node_free_standard_storage(bNode *node)
Definition node_util.cc:45
VecBase< float, 3 > float3
@ PROP_FACTOR
Definition RNA_types.hh:308
signed char int8_t
Definition BKE_text.h:76
void common_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
#define hash
Definition noise_c.cc:156
#define min(a, b)
Definition sort.cc:38
eNodeSocketDatatype type
struct bNodeSocket * next
eNodeTree_Type type
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:290
std::string ui_description
Definition BKE_node.hh:271
void(*) updatefunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:312
void(*) labelfunc(const bNodeTree *ntree, const bNode *node, char *label, int label_maxncpy)
Definition BKE_node.hh:301
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
NodeMultiFunctionBuildFunction build_multi_function
Definition BKE_node.hh:382
void(*) initfunc(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:320
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393
int(*) ui_class(const bNode *node)
Definition BKE_node.hh:307
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)