Blender V5.3
node_shader_bsdf_toon.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
9#include "node_shader_util.hh"
10
12#include "UI_resources.hh"
13
14namespace blender {
15
17
19{
20 const bNodeTree *ntree = b.tree_or_null();
21 const bool is_gpu_internal = ntree && (ntree->flag & NTREE_IS_GPU_SHADER_INTERNAL);
22
23 b.add_input<decl::Color>("Color"_ustr).default_value({0.8f, 0.8f, 0.8f, 1.0f});
24 b.add_input<decl::Float>("Size"_ustr)
25 .default_value(0.5f)
26 .min(0.0f)
27 .max(1.0f)
29 b.add_input<decl::Float>("Smooth"_ustr)
30 .default_value(0.0f)
31 .min(0.0f)
32 .max(1.0f)
34 b.add_input<decl::Vector>("Normal"_ustr).hide_value();
35 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
36 b.add_output<decl::Shader>("BSDF"_ustr);
37}
38
39static void node_shader_buts_toon(ui::Layout &layout, bContext * /*C*/, PointerRNA *ptr)
40{
41 layout.prop(ptr, "component", ui::ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
42}
43
45 bNode *node,
46 bNodeExecData * /*execdata*/,
49{
50 if (!in[3].link) {
51 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[3].link);
52 }
53
55
56 return GPU_stack_link(
57 mat, node, "node_bsdf_toon", in, out, GPU_kernel_globals(), GPU_shading_data());
58}
59
60} // namespace nodes::node_shader_bsdf_toon_cc
61
62/* node type definition */
64{
65 namespace file_ns = nodes::node_shader_bsdf_toon_cc;
66
67 static bke::bNodeType ntype;
68
69 sh_node_type_base(&ntype, "ShaderNodeBsdfToon"_ustr, SH_NODE_BSDF_TOON);
70 ntype.ui_name = "Toon BSDF";
71 ntype.ui_description = "Diffuse and Glossy shaders with cartoon light effects";
72 ntype.enum_name_legacy = "BSDF_TOON";
74 ntype.declare = file_ns::node_declare;
77 ntype.draw_buttons = file_ns::node_shader_buts_toon;
79 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_toon;
80
82}
83
84} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_BSDF_TOON
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_shader_buts_toon(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
bool object_cycles_shader_nodes_poll(const bContext *C)
@ GPU_MATFLAG_DIFFUSE
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bool GPU_link(GPUMaterial *mat, const char *name,...)
void search_link_ops_for_shader_bsdf_node(nodes::GatherLinkSearchOpParams &params)
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
GPUNodeLink * GPU_shading_data()
void register_node_type_sh_bsdf_toon()
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
@ PROP_FACTOR
Definition RNA_types.hh:308
eNodeTree_Flag flag
static constexpr int _160
Definition BKE_node.hh:246
Defines a node type.
Definition BKE_node.hh:265
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:290
std::string ui_description
Definition BKE_node.hh:271
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:373
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
Definition BKE_node.hh:409
NodeDeclareFunction declare
Definition BKE_node.hh:393
bool(*) add_ui_poll(const bContext *C)
Definition BKE_node.hh:341
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)