Blender V4.3
node_shader_bsdf_transparent.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
7#include "BLI_math_vector.h"
8
10
12{
13 b.add_input<decl::Color>("Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
14 b.add_input<decl::Float>("Weight").available(false);
15 b.add_output<decl::Shader>("BSDF");
16}
17
19 bNode *node,
20 bNodeExecData * /*execdata*/,
21 GPUNodeStack *in,
22 GPUNodeStack *out)
23{
24 if (in[0].link || !is_zero_v3(in[0].vec)) {
26 }
27 return GPU_stack_link(mat, node, "node_bsdf_transparent", in, out);
28}
29
31#ifdef WITH_MATERIALX
32{
33 switch (to_type_) {
34 case NodeItem::Type::BSDF: {
35 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
36 /* Returning diffuse node as BSDF component */
37 return create_node("oren_nayar_diffuse_bsdf", NodeItem::Type::BSDF, {{"color", color}});
38 }
39 case NodeItem::Type::SurfaceOpacity: {
40 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
41 /* Returning: 1 - <average of color components> */
42 return val(1.0f) - color.dotproduct(val(1.0f / 3.0f));
43 }
44 default:
45 break;
46 }
47 return empty();
48}
49#endif
51
52} // namespace blender::nodes::node_shader_bsdf_transparent_cc
53
54/* node type definition */
56{
58
59 static blender::bke::bNodeType ntype;
60
61 sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSPARENT, "Transparent BSDF", NODE_CLASS_SHADER);
63 ntype.declare = file_ns::node_declare;
64 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_transparent;
65 ntype.materialx_fn = file_ns::node_shader_materialx;
66
68}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:417
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_TRANSPARENT
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static int node_shader_gpu_bsdf_transparent(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_bsdf_transparent()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
bool object_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
bool(* add_ui_poll)(const bContext *C)
Definition BKE_node.hh:288
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347