Blender V5.0
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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_input<decl::Color>("Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
12 b.add_input<decl::Vector>("Normal").hide_value();
13 b.add_input<decl::Float>("Weight").available(false);
14 b.add_output<decl::Shader>("BSDF");
15}
16
18 bNode *node,
19 bNodeExecData * /*execdata*/,
22{
23 if (!in[1].link) {
24 GPU_link(mat, "world_normals_get", &in[1].link);
25 }
26
28
29 return GPU_stack_link(mat, node, "node_bsdf_translucent", in, out);
30}
31
33#ifdef WITH_MATERIALX
34{
35 if (to_type_ != NodeItem::Type::BSDF) {
36 return empty();
37 }
38
39 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
40 NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3);
41
42 return create_node(
43 "translucent_bsdf", NodeItem::Type::BSDF, {{"color", color}, {"normal", normal}});
44}
45#endif
47
48} // namespace blender::nodes::node_shader_bsdf_translucent_cc
49
50/* node type definition */
52{
54
55 static blender::bke::bNodeType ntype;
56
57 sh_node_type_base(&ntype, "ShaderNodeBsdfTranslucent", SH_NODE_BSDF_TRANSLUCENT);
58 ntype.ui_name = "Translucent BSDF";
59 ntype.ui_description = "Lambertian diffuse transmission";
60 ntype.enum_name_legacy = "BSDF_TRANSLUCENT";
62 ntype.declare = file_ns::node_declare;
64 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_translucent;
65 ntype.materialx_fn = file_ns::node_shader_materialx;
66
68}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define SH_NODE_BSDF_TRANSLUCENT
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_TRANSLUCENT
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
bool GPU_link(GPUMaterial *mat, const char *name,...)
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static int node_shader_gpu_bsdf_translucent(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_translucent()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool object_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:238
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:344
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
NodeDeclareFunction declare
Definition BKE_node.hh:362