Blender V5.3
node_shader_output_material.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 b.add_input<decl::Shader>("Surface"_ustr);
18 b.add_input<decl::Shader>("Volume"_ustr).translation_context(BLT_I18NCONTEXT_ID_ID);
19 b.add_input<decl::Vector>("Displacement"_ustr).hide_value();
20 b.add_input<decl::Float>("Thickness"_ustr).hide_value();
21}
22
24 bNode * /*node*/,
25 bNodeExecData * /*execdata*/,
27 GPUNodeStack * /*out*/)
28{
29 GPUNodeLink *outlink_surface, *outlink_volume, *outlink_displacement, *outlink_thickness;
30 /* Passthrough node in order to do the right socket conversions (important for displacement). */
31 if (in[0].link) {
32 GPU_link(mat, "node_output_material_surface", in[0].link, &outlink_surface);
33 GPU_material_output_surface(mat, outlink_surface);
34 }
35 if (in[1].link) {
36 GPU_link(mat, "node_output_material_volume", in[1].link, &outlink_volume);
37 GPU_material_output_volume(mat, outlink_volume);
38 }
39 if (in[2].link) {
40 GPU_link(mat, "node_output_material_displacement", in[2].link, &outlink_displacement);
41 GPU_material_output_displacement(mat, outlink_displacement);
42 }
43 if (in[3].link) {
44 GPU_link(mat,
45 "node_output_material_thickness",
46 in[3].link,
49 &outlink_thickness);
50 GPU_material_output_thickness(mat, outlink_thickness);
51 }
52 return true;
53}
54
56#ifdef WITH_MATERIALX
57{
58 NodeItem surface = get_input_link("Surface", NodeItem::Type::SurfaceShader);
59 if (!surface) {
60 NodeItem bsdf = get_input_link("Surface", NodeItem::Type::BSDF);
61 NodeItem edf = get_input_link("Surface", NodeItem::Type::EDF);
62 if (bsdf || edf) {
63 NodeItem opacity = get_input_link("Surface", NodeItem::Type::SurfaceOpacity);
64 surface = create_node("surface",
65 NodeItem::Type::SurfaceShader,
66 {{"bsdf", bsdf}, {"edf", edf}, {"opacity", opacity}});
67 }
68 }
69
70 /* Displacement cannot be enabled just yet.
71 * - Verify coordinate system for Tangent Space displacement maps
72 * - Wait on fix for scalar displacement (present in USD 2408+)
73 */
74 // NodeItem displacement = get_input_link("Displacement", NodeItem::Type::DisplacementShader);
75 // return create_node("surfacematerial",
76 // NodeItem::Type::Material,
77 // {{"surfaceshader", surface}, {"displacementshader", displacement}});
78 return create_node("surfacematerial", NodeItem::Type::Material, {{"surfaceshader", surface}});
79}
80#endif
82
83} // namespace nodes::node_shader_output_material_cc
84
85/* node type definition */
87{
88 namespace file_ns = nodes::node_shader_output_material_cc;
89
90 static bke::bNodeType ntype;
91
92 sh_node_type_base(&ntype, "ShaderNodeOutputMaterial"_ustr, SH_NODE_OUTPUT_MATERIAL);
93 ntype.ui_name = "Material Output";
94 ntype.ui_description = "Output surface material information for use in rendering";
95 ntype.enum_name_legacy = "OUTPUT_MATERIAL";
97 ntype.declare = file_ns::node_declare;
99 ntype.gpu_fn = file_ns::node_shader_gpu_output_material;
100 ntype.materialx_fn = file_ns::node_shader_materialx;
101
102 ntype.no_muting = true;
103
105}
106
107} // namespace blender
#define NODE_CLASS_OUTPUT
Definition BKE_node.hh:479
#define SH_NODE_OUTPUT_MATERIAL
#define BLT_I18NCONTEXT_ID_ID
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static void node_declare(NodeDeclarationBuilder &b)
static int node_shader_gpu_output_material(GPUMaterial *mat, bNode *, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *)
BMesh Iterators.
bool object_shader_nodes_poll(const bContext *C)
void GPU_material_output_surface(GPUMaterial *material, GPUNodeLink *link)
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
bool GPU_link(GPUMaterial *mat, const char *name,...)
void GPU_material_output_displacement(GPUMaterial *material, GPUNodeLink *link)
void register_node_type_sh_output_material()
void GPU_material_output_volume(GPUMaterial *material, GPUNodeLink *link)
GPUNodeLink * GPU_shading_data()
GPUNodeLink * GPU_kernel_globals()
void GPU_material_output_thickness(GPUMaterial *material, GPUNodeLink *link)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
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
NodeDeclareFunction declare
Definition BKE_node.hh:393
bool(*) add_ui_poll(const bContext *C)
Definition BKE_node.hh:341