Blender V5.3
node_shader_volume_absorption.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#define SOCK_COLOR_ID 0
22 b.add_input<decl::Float>("Density"_ustr).default_value(1.0f).min(0.0f).max(1000.0f);
23#define SOCK_DENSITY_ID 1
24 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
25 b.add_output<decl::Shader>("Volume"_ustr).translation_context(BLT_I18NCONTEXT_ID_ID);
26}
27
29 bNode *node,
30 bNodeExecData * /*execdata*/,
33{
34 if (in[SOCK_DENSITY_ID].socket_not_zero() && in[SOCK_COLOR_ID].socket_not_white()) {
36 }
37 return GPU_stack_link(
38 mat, node, "node_volume_absorption", in, out, GPU_kernel_globals(), GPU_shading_data());
39}
40
41#undef SOCK_COLOR_ID
42#undef SOCK_DENSITY_ID
43
44} // namespace nodes::node_shader_volume_absorption_cc
45
46/* node type definition */
48{
50
51 static bke::bNodeType ntype;
52
53 sh_node_type_base(&ntype, "ShaderNodeVolumeAbsorption"_ustr, SH_NODE_VOLUME_ABSORPTION);
54 ntype.ui_name = "Volume Absorption";
55 ntype.ui_description = "Absorb light as it passes through the volume";
56 ntype.enum_name_legacy = "VOLUME_ABSORPTION";
58 ntype.declare = file_ns::node_declare;
60 ntype.gpu_fn = file_ns::node_shader_gpu_volume_absorption;
61
63}
64
65} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_VOLUME_ABSORPTION
#define BLT_I18NCONTEXT_ID_ID
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int node_shader_gpu_volume_absorption(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,...)
void register_node_type_sh_volume_absorption()
@ GPU_MATFLAG_VOLUME_ABSORPTION
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
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 SOCK_DENSITY_ID
#define SOCK_COLOR_ID
eNodeTree_Flag flag
Defines a node type.
Definition BKE_node.hh:265
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