Blender V5.3
node_shader_bsdf_translucent.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
11namespace blender {
12
14
16{
17 const bNodeTree *ntree = b.tree_or_null();
18 const bool is_gpu_internal = ntree && (ntree->flag & NTREE_IS_GPU_SHADER_INTERNAL);
19
20 b.add_input<decl::Color>("Color"_ustr).default_value({0.8f, 0.8f, 0.8f, 1.0f});
21 b.add_input<decl::Vector>("Normal"_ustr).hide_value();
22 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
23 b.add_output<decl::Shader>("BSDF"_ustr);
24}
25
27 bNode *node,
28 bNodeExecData * /*execdata*/,
31{
32 if (!in[1].link) {
33 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[1].link);
34 }
35
37
38 return GPU_stack_link(
39 mat, node, "node_bsdf_translucent", in, out, GPU_kernel_globals(), GPU_shading_data());
40}
41
43#ifdef WITH_MATERIALX
44{
45 if (to_type_ != NodeItem::Type::BSDF) {
46 return empty();
47 }
48
49 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
50 NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
51
52 return create_node(
53 "translucent_bsdf", NodeItem::Type::BSDF, {{"color", color}, {"normal", normal}});
54}
55#endif
57
58} // namespace nodes::node_shader_bsdf_translucent_cc
59
60/* node type definition */
62{
64
65 static bke::bNodeType ntype;
66
67 sh_node_type_base(&ntype, "ShaderNodeBsdfTranslucent"_ustr, SH_NODE_BSDF_TRANSLUCENT);
68 ntype.ui_name = "Translucent BSDF";
69 ntype.ui_description = "Lambertian diffuse transmission";
70 ntype.enum_name_legacy = "BSDF_TRANSLUCENT";
72 ntype.declare = file_ns::node_declare;
75 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_translucent;
76 ntype.materialx_fn = file_ns::node_shader_materialx;
77
79}
80
81} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_BSDF_TRANSLUCENT
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int node_shader_gpu_bsdf_translucent(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_shader_nodes_poll(const bContext *C)
@ GPU_MATFLAG_TRANSLUCENT
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void register_node_type_sh_bsdf_translucent()
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()
@ NTREE_IS_GPU_SHADER_INTERNAL
GPUNodeLink * GPU_kernel_globals()
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
eNodeTree_Flag flag
Defines a node type.
Definition BKE_node.hh:265
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:375
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