17 b.add_input<
decl::Vector>(
"Vector").
min(-10000.0f).max(10000.0f).implicit_field(
20 .default_value({0.8f, 0.8f, 0.8f, 1.0f})
21 .description(
"Color of the first checker");
23 .default_value({0.2f, 0.2f, 0.2f, 1.0f})
24 .description(
"Color of the second checker");
31 "Overall texture scale.\n"
32 "The scale is a factor of the bounding box of the face divided by the Scale value");
62 static const mf::Signature
signature = []() {
64 mf::SignatureBuilder builder{
"Checker",
signature};
65 builder.single_input<
float3>(
"Vector");
68 builder.single_input<
float>(
"Scale");
69 builder.single_output<
ColorGeometry4f>(
"Color", mf::ParamFlag::SupportsUnusedOutput);
70 builder.single_output<
float>(
"Fac");
96 r_fac[
i] = ((xi % 2 == yi % 2) == (zi % 2)) ? 1.0f : 0.0f;
99 if (!r_color.is_empty()) {
101 [&](
const int64_t i) { r_color[
i] = (r_fac[
i] == 1.0f) ? color1[
i] : color2[
i]; });
115 NodeItem
vector = get_input_link(
"Vector", NodeItem::Type::Vector2);
119 NodeItem value1 = val(1.0f);
120 NodeItem value2 = val(0.0f);
121 if (
STREQ(socket_out_->identifier,
"Color")) {
122 value1 = get_input_value(
"Color1", NodeItem::Type::Color3);
123 value2 = get_input_value(
"Color2", NodeItem::Type::Color3);
125 NodeItem scale = get_input_value(
"Scale", NodeItem::Type::Float);
129 .if_else(NodeItem::CompareOp::Eq, val(1.0f), value1, value2);
143 ntype.
ui_name =
"Checker Texture";
147 ntype.
declare = file_ns::sh_node_tex_checker_declare;
148 ntype.
initfunc = file_ns::node_shader_init_tex_checker;
151 ntype.
gpu_fn = file_ns::node_shader_gpu_tex_checker;
#define NODE_CLASS_TEXTURE
#define SH_NODE_TEX_CHECKER
void BKE_texture_mapping_default(struct TexMapping *texmap, int type)
void BKE_texture_colormapping_default(struct ColorMapping *colormap)
@ NODE_DEFAULT_INPUT_POSITION_FIELD
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
const Signature & signature() const
void set_signature(const Signature *signature)
void set_matching_fn(const mf::MultiFunction *fn)
void call(const IndexMask &mask, mf::Params params, mf::Context) const override
void * MEM_callocN(size_t len, const char *str)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
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))
static void sh_node_tex_checker_declare(NodeDeclarationBuilder &b)
static void sh_node_tex_checker_build_multi_function(NodeMultiFunctionBuilder &builder)
static void node_shader_init_tex_checker(bNodeTree *, bNode *node)
static int node_shader_gpu_tex_checker(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_tex_checker()
void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *)
void node_shader_gpu_default_tex_coord(GPUMaterial *mat, bNode *node, GPUNodeLink **link)
void common_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
NodeMaterialXFunction materialx_fn
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeDeclareFunction declare