Blender V5.3
node_texture_checker.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
10#include <cmath>
11
12namespace blender {
13
15 {SOCK_RGBA, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f},
16 {SOCK_RGBA, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f},
17 {SOCK_FLOAT, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED},
18 {-1, ""},
19};
21 {SOCK_RGBA, N_("Color")},
22 {-1, ""},
23};
24
25static void colorfn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
26{
27 float x = p->co[0];
28 float y = p->co[1];
29 float z = p->co[2];
30 float sz = tex_input_value(in[2], p, thread);
31
32 /* 0.00001 because of unit sized stuff */
33 int xi = int(fabs(floor(0.00001f + x / sz)));
34 int yi = int(fabs(floor(0.00001f + y / sz)));
35 int zi = int(fabs(floor(0.00001f + z / sz)));
36
37 if ((xi % 2 == yi % 2) == (zi % 2)) {
38 tex_input_rgba(out, in[0], p, thread);
39 }
40 else {
41 tex_input_rgba(out, in[1], p, thread);
42 }
43}
44
45static void exec(void *data,
46 int /*thread*/,
47 bNode *node,
48 bNodeExecData *execdata,
49 bNodeStack **in,
51{
52 tex_output(node, execdata, in, out[0], &colorfn, static_cast<TexCallData *>(data));
53}
54
56{
57 static bke::bNodeType ntype;
58
59 tex_node_type_base(&ntype, "TextureNodeChecker"_ustr, TEX_NODE_CHECKER);
60 ntype.ui_name = "Checker";
61 ntype.enum_name_legacy = "CHECKER";
64 ntype.exec_fn = exec;
65 ntype.flag |= NODE_PREVIEW;
66
68}
69
70} // namespace blender
#define NODE_CLASS_PATTERN
Definition BKE_node.hh:487
#define TEX_NODE_CHECKER
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
#define floor
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:6134
BMesh Iterators.
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void register_node_type_tex_checker()
static void colorfn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
BMesh const char void * data
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
static bke::bNodeSocketTemplate inputs[]
void tex_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
static bke::bNodeSocketTemplate outputs[]
@ PROP_UNSIGNED
Definition RNA_types.hh:306
Compact definition of a node socket.
Definition BKE_node.hh:102
Defines a node type.
Definition BKE_node.hh:265
NodeExecFunction exec_fn
Definition BKE_node.hh:371
const char * enum_name_legacy
Definition BKE_node.hh:274
#define N_(msgid)