Blender  V3.3
node_shader_bsdf_anisotropic.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2005 Blender Foundation. All rights reserved. */
3 
4 #include "node_shader_util.hh"
5 
6 #include "UI_interface.h"
7 #include "UI_resources.h"
8 
10 
12 {
13  b.add_input<decl::Color>(N_("Color")).default_value({0.8f, 0.8f, 0.8f, 1.0f});
14  b.add_input<decl::Float>(N_("Roughness"))
15  .default_value(0.5f)
16  .min(0.0f)
17  .max(1.0f)
18  .subtype(PROP_FACTOR);
19  b.add_input<decl::Float>(N_("Anisotropy")).default_value(0.5f).min(-1.0f).max(1.0f);
20  b.add_input<decl::Float>(N_("Rotation"))
21  .default_value(0.0f)
22  .min(0.0f)
23  .max(1.0f)
24  .subtype(PROP_FACTOR);
25  b.add_input<decl::Vector>(N_("Normal")).hide_value();
26  b.add_input<decl::Vector>(N_("Tangent")).hide_value();
27  b.add_input<decl::Float>(N_("Weight")).unavailable();
28  b.add_output<decl::Shader>(N_("BSDF"));
29 }
30 
32 {
33  uiItemR(layout, ptr, "distribution", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
34 }
35 
37 {
38  node->custom1 = SHD_GLOSSY_GGX;
39 }
40 
42  bNode *node,
43  bNodeExecData *UNUSED(execdata),
44  GPUNodeStack *in,
46 {
47  if (!in[4].link) {
48  GPU_link(mat, "world_normals_get", &in[4].link);
49  }
50 
52 
53  float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f;
54 
55  return GPU_stack_link(
56  mat, node, "node_bsdf_anisotropic", in, out, GPU_constant(&use_multi_scatter));
57 }
58 
59 } // namespace blender::nodes::node_shader_bsdf_anisotropic_cc
60 
61 /* node type definition */
63 {
65 
66  static bNodeType ntype;
67 
68  sh_node_type_base(&ntype, SH_NODE_BSDF_ANISOTROPIC, "Anisotropic BSDF", NODE_CLASS_SHADER);
74 
75  nodeRegisterType(&ntype);
76 }
void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn)
Definition: node.cc:4465
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
Definition: node.cc:4408
#define SH_NODE_BSDF_ANISOTROPIC
Definition: BKE_node.h:1108
#define NODE_CLASS_SHADER
Definition: BKE_node.h:358
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
@ NODE_SIZE_MIDDLE
Definition: BKE_node.h:366
#define UNUSED(x)
#define SHD_GLOSSY_GGX
#define SHD_GLOSSY_MULTI_GGX
GPUNodeLink * GPU_constant(const float *num)
@ GPU_MATFLAG_GLOSSY
Definition: GPU_material.h:73
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
Definition: gpu_material.c:596
bool GPU_link(GPUMaterial *mat, const char *name,...)
bool GPU_stack_link(GPUMaterial *mat, struct bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ PROP_FACTOR
Definition: RNA_types.h:144
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
OperationNode * node
bNodeTree * ntree
static void node_shader_init_anisotropic(bNodeTree *UNUSED(ntree), bNode *node)
static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static void node_shader_buts_anisotropic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_sh_bsdf_anisotropic()
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition: BKE_node.h:226
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:244
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480