Blender V5.0
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
13 {SOCK_RGBA, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f},
14 {SOCK_RGBA, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f},
15 {SOCK_FLOAT, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED},
16 {-1, ""},
17};
19 {SOCK_RGBA, N_("Color")},
20 {-1, ""},
21};
22
23static void colorfn(float *out, TexParams *p, bNode * /*node*/, bNodeStack **in, short thread)
24{
25 float x = p->co[0];
26 float y = p->co[1];
27 float z = p->co[2];
28 float sz = tex_input_value(in[2], p, thread);
29
30 /* 0.00001 because of unit sized stuff */
31 int xi = int(fabs(floor(0.00001f + x / sz)));
32 int yi = int(fabs(floor(0.00001f + y / sz)));
33 int zi = int(fabs(floor(0.00001f + z / sz)));
34
35 if ((xi % 2 == yi % 2) == (zi % 2)) {
36 tex_input_rgba(out, in[0], p, thread);
37 }
38 else {
39 tex_input_rgba(out, in[1], p, thread);
40 }
41}
42
43static void exec(void *data,
44 int /*thread*/,
45 bNode *node,
46 bNodeExecData *execdata,
47 bNodeStack **in,
49{
50 tex_output(node, execdata, in, out[0], &colorfn, static_cast<TexCallData *>(data));
51}
52
54{
55 static blender::bke::bNodeType ntype;
56
57 tex_node_type_base(&ntype, "TextureNodeChecker", TEX_NODE_CHECKER);
58 ntype.ui_name = "Checker";
59 ntype.enum_name_legacy = "CHECKER";
62 ntype.exec_fn = exec;
63 ntype.flag |= NODE_PREVIEW;
64
66}
#define NODE_CLASS_PATTERN
Definition BKE_node.hh:456
#define TEX_NODE_CHECKER
@ NODE_PREVIEW
@ SOCK_FLOAT
@ SOCK_RGBA
@ PROP_UNSIGNED
Definition RNA_types.hh:249
BMesh const char void * data
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
#define in
#define out
#define floor
ccl_device_inline float2 fabs(const float2 a)
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:5352
static blender::bke::bNodeSocketTemplate outputs[]
static void colorfn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
static blender::bke::bNodeSocketTemplate inputs[]
void register_node_type_tex_checker()
static void colorfn(float *out, TexParams *p, bNode *, bNodeStack **in, short thread)
static void exec(void *data, int, bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_output(bNode *node, bNodeExecData *, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
const float * co
Compact definition of a node socket.
Definition BKE_node.hh:99
Defines a node type.
Definition BKE_node.hh:238
NodeExecFunction exec_fn
Definition BKE_node.hh:340
const char * enum_name_legacy
Definition BKE_node.hh:247
#define N_(msgid)