Blender V4.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
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,
48 bNodeStack **out)
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, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN);
58 blender::bke::node_type_socket_templates(&ntype, inputs, outputs);
59 ntype.exec_fn = exec;
60 ntype.flag |= NODE_PREVIEW;
61
63}
#define NODE_CLASS_PATTERN
Definition BKE_node.hh:413
@ NODE_PREVIEW
@ SOCK_FLOAT
@ SOCK_RGBA
@ PROP_UNSIGNED
Definition RNA_types.hh:152
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float2 fabs(const float2 a)
void node_type_socket_templates(bNodeType *ntype, bNodeSocketTemplate *inputs, bNodeSocketTemplate *outputs)
Definition node.cc:4570
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
float tex_input_value(bNodeStack *in, TexParams *params, short thread)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
const float * co
Compact definition of a node socket.
Definition BKE_node.hh:103
Defines a node type.
Definition BKE_node.hh:218
NodeExecFunction exec_fn
Definition BKE_node.hh:316
#define N_(msgid)