Blender  V3.3
node_shader_bsdf_glass.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 
7 
9 {
10  b.add_input<decl::Color>(N_("Color")).default_value({1.0f, 1.0f, 1.0f, 1.0f});
11  b.add_input<decl::Float>(N_("Roughness"))
12  .default_value(0.0f)
13  .min(0.0f)
14  .max(1.0f)
15  .subtype(PROP_FACTOR);
16  b.add_input<decl::Float>(N_("IOR")).default_value(1.45f).min(0.0f).max(1000.0f);
17  b.add_input<decl::Vector>(N_("Normal")).hide_value();
18  b.add_input<decl::Float>(N_("Weight")).unavailable();
19  b.add_output<decl::Shader>(N_("BSDF"));
20 }
21 
23 {
24  node->custom1 = SHD_GLOSSY_BECKMANN;
25 }
26 
28  bNode *node,
29  bNodeExecData *UNUSED(execdata),
30  GPUNodeStack *in,
32 {
33  if (!in[3].link) {
34  GPU_link(mat, "world_normals_get", &in[3].link);
35  }
36 
37  if (node->custom1 == SHD_GLOSSY_SHARP) {
38  GPU_link(mat, "set_value_zero", &in[1].link);
39  }
40 
42 
43  float use_multi_scatter = (node->custom1 == SHD_GLOSSY_MULTI_GGX) ? 1.0f : 0.0f;
44 
45  return GPU_stack_link(mat, node, "node_bsdf_glass", in, out, GPU_constant(&use_multi_scatter));
46 }
47 
48 } // namespace blender::nodes::node_shader_bsdf_glass_cc
49 
50 /* node type definition */
52 {
54 
55  static bNodeType ntype;
56 
62 
63  nodeRegisterType(&ntype);
64 }
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_GLASS
Definition: BKE_node.h:1111
#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_SHARP
#define SHD_GLOSSY_BECKMANN
#define SHD_GLOSSY_MULTI_GGX
GPUNodeLink * GPU_constant(const float *num)
@ GPU_MATFLAG_GLOSSY
Definition: GPU_material.h:73
@ GPU_MATFLAG_REFRACT
Definition: GPU_material.h:74
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
OperationNode * node
bNodeTree * ntree
static void node_declare(NodeDeclarationBuilder &b)
static void node_shader_init_glass(bNodeTree *UNUSED(ntree), bNode *node)
static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
static const pxr::TfToken out("out", pxr::TfToken::Immortal)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_sh_bsdf_glass()
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass)
Defines a node type.
Definition: BKE_node.h:226
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)