Blender V4.3
node_shader_normal.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
9#include "node_shader_util.hh"
10
12
14{
15 b.add_input<decl::Vector>("Normal")
16 .default_value({0.0f, 0.0f, 1.0f})
17 .min(-1.0f)
18 .max(1.0f)
20 .description(
21 "Normal direction vector.\n"
22 "\u2022 LMB click and drag on the sphere to set the direction of the normal.\n"
23 "\u2022 Holding Ctrl while dragging snaps to 45 degree rotation increments");
24 b.add_output<decl::Vector>("Normal")
25 .default_value({0.0f, 0.0f, 1.0f})
26 .min(-1.0f)
27 .max(1.0f)
29 b.add_output<decl::Float>("Dot");
30}
31
33 bNode *node,
34 bNodeExecData * /*execdata*/,
35 GPUNodeStack *in,
36 GPUNodeStack *out)
37{
38 GPUNodeLink *vec = GPU_uniform(out[0].vec);
39 return GPU_stack_link(mat, node, "normal_new_shading", in, out, vec);
40}
41
43#ifdef WITH_MATERIALX
44{
45 NodeItem res = get_output_default("Normal", NodeItem::Type::Vector3);
46
47 if (STREQ(socket_out_->name, "Dot")) {
48 return res.dotproduct(get_input_value("Normal", NodeItem::Type::Vector3));
49 }
50
51 return res;
52}
53#endif
55
56} // namespace blender::nodes::node_shader_normal_cc
57
59{
60 namespace file_ns = blender::nodes::node_shader_normal_cc;
61
62 static blender::bke::bNodeType ntype;
63
65 ntype.declare = file_ns::node_declare;
66 ntype.gpu_fn = file_ns::gpu_shader_normal;
67 ntype.materialx_fn = file_ns::node_shader_materialx;
68
70}
#define SH_NODE_NORMAL
Definition BKE_node.hh:898
#define NODE_CLASS_OP_VECTOR
Definition BKE_node.hh:407
#define STREQ(a, b)
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_uniform(const float *num)
@ PROP_DIRECTION
Definition RNA_types.hh:165
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void node_declare(NodeDeclarationBuilder &b)
static int gpu_shader_normal(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_normal()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
#define min(a, b)
Definition sort.c:32
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347