Blender V5.0
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
5#include "node_shader_util.hh"
6
8#include "UI_resources.hh"
9
11
13{
14 b.add_input<decl::Color>("Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
15 b.add_input<decl::Float>("Size").default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
16 b.add_input<decl::Float>("Smooth").default_value(0.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
17 b.add_input<decl::Vector>("Normal").hide_value();
18 b.add_input<decl::Float>("Weight").available(false);
19 b.add_output<decl::Shader>("BSDF");
20}
21
22static void node_shader_buts_toon(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
23{
24 layout->prop(ptr, "component", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
25}
26
28 bNode *node,
29 bNodeExecData * /*execdata*/,
32{
33 if (!in[3].link) {
34 GPU_link(mat, "world_normals_get", &in[3].link);
35 }
36
38
39 return GPU_stack_link(mat, node, "node_bsdf_toon", in, out);
40}
41
42} // namespace blender::nodes::node_shader_bsdf_toon_cc
43
44/* node type definition */
46{
48
49 static blender::bke::bNodeType ntype;
50
51 sh_node_type_base(&ntype, "ShaderNodeBsdfToon", SH_NODE_BSDF_TOON);
52 ntype.ui_name = "Toon BSDF";
53 ntype.ui_description = "Diffuse and Glossy shaders with cartoon light effects";
54 ntype.enum_name_legacy = "BSDF_TOON";
56 ntype.declare = file_ns::node_declare;
58 ntype.draw_buttons = file_ns::node_shader_buts_toon;
60 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_toon;
61
63}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define SH_NODE_BSDF_TOON
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_DIFFUSE
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
bool GPU_link(GPUMaterial *mat, const char *name,...)
@ PROP_FACTOR
Definition RNA_types.hh:251
@ UI_ITEM_R_SPLIT_EMPTY_NAME
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void node_type_size_preset(bNodeType &ntype, eNodeSizePreset size)
Definition node.cc:5396
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_bsdf_toon(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_toon(uiLayout *layout, bContext *, PointerRNA *ptr)
void register_node_type_sh_bsdf_toon()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool object_cycles_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
bool(* add_ui_poll)(const bContext *C)
Definition BKE_node.hh:310
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:342
const char * enum_name_legacy
Definition BKE_node.hh:247
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
Definition BKE_node.hh:259
NodeDeclareFunction declare
Definition BKE_node.hh:362
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
PointerRNA * ptr
Definition wm_files.cc:4238