Blender V5.3
node_shader_eevee_specular.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
11#include "BLI_math_base_c.hh"
12
13namespace blender {
14
16
18{
19 const bNodeTree *ntree = b.tree_or_null();
20 const bool is_gpu_internal = ntree && (ntree->flag & NTREE_IS_GPU_SHADER_INTERNAL);
21
22 b.add_input<decl::Color>("Base Color"_ustr).default_value({0.8f, 0.8f, 0.8f, 1.0f});
23 b.add_input<decl::Color>("Specular"_ustr).default_value({0.03f, 0.03f, 0.03f, 1.0f});
24 b.add_input<decl::Float>("Roughness"_ustr)
25 .default_value(0.2f)
26 .min(0.0f)
27 .max(1.0f)
29 b.add_input<decl::Color>("Emissive Color"_ustr).default_value({0.0f, 0.0f, 0.0f, 1.0f});
30 b.add_input<decl::Float>("Transparency"_ustr)
31 .default_value(0.0f)
32 .min(0.0f)
33 .max(1.0f)
35 b.add_input<decl::Vector>("Normal"_ustr).hide_value();
36 b.add_input<decl::Float>("Clear Coat"_ustr)
37 .default_value(0.0f)
38 .min(0.0f)
39 .max(1.0f)
41 b.add_input<decl::Float>("Clear Coat Roughness"_ustr)
42 .default_value(0.0f)
43 .min(0.0f)
44 .max(1.0f)
46 b.add_input<decl::Vector>("Clear Coat Normal"_ustr).hide_value();
47 b.add_input<decl::Float>("Weight"_ustr).available(is_gpu_internal);
48 b.add_output<decl::Shader>("BSDF"_ustr);
49}
50
52 bNode *node,
53 bNodeExecData * /*execdata*/,
56{
57 /* Normals */
58 if (!in[5].link) {
59 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[5].link);
60 }
61
62 /* Coat Normals */
63 if (!in[8].link) {
64 GPU_link(mat, "world_normals_get", GPU_shading_data(), &in[8].link);
65 }
66
67 bool use_transparency = in[4].socket_not_zero();
68 bool use_coat = in[6].socket_not_zero();
69
71
72 if (in[1].might_be_tinted()) {
74 }
75 if (use_coat) {
76 flag |= GPU_MATFLAG_COAT;
77 }
78 if (use_transparency) {
80 }
81
82 GPU_material_flag_set(mat, flag);
83
84 float use_coat_f = use_coat ? 1.0f : 0.0f;
85 return GPU_stack_link(mat,
86 node,
87 "node_eevee_specular",
88 in,
89 out,
90 GPU_constant(&use_coat_f),
93}
94
95} // namespace nodes::node_shader_eevee_specular_cc
96
97/* node type definition */
99{
100 namespace file_ns = nodes::node_shader_eevee_specular_cc;
101
102 static bke::bNodeType ntype;
103
104 sh_node_type_base(&ntype, "ShaderNodeEeveeSpecular"_ustr, SH_NODE_EEVEE_SPECULAR);
105 ntype.ui_name = "Specular BSDF";
106 ntype.ui_description =
107 "Similar to the Principled BSDF node but uses the specular workflow instead of metallic, "
108 "which functions by specifying the facing (along normal) reflection color. Energy is not "
109 "conserved, so the result may not be physically accurate";
110 ntype.enum_name_legacy = "EEVEE_SPECULAR";
112 ntype.declare = file_ns::node_declare;
115 ntype.gpu_fn = file_ns::node_shader_gpu_eevee_specular;
116
118}
119
120} // namespace blender
#define NODE_CLASS_SHADER
Definition BKE_node.hh:491
#define SH_NODE_EEVEE_SPECULAR
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
BMesh Iterators.
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_COAT
@ GPU_MATFLAG_GLOSSY
@ GPU_MATFLAG_DIFFUSE
@ GPU_MATFLAG_REFLECTION_MAYBE_COLORED
@ GPU_MATFLAG_TRANSPARENT
void sh_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
GPUNodeLink * GPU_constant(const float *num)
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)
bool object_eevee_shader_nodes_poll(const bContext *C)
GPUNodeLink * GPU_shading_data()
@ NTREE_IS_GPU_SHADER_INTERNAL
void register_node_type_sh_eevee_specular()
GPUNodeLink * GPU_kernel_globals()
@ PROP_FACTOR
Definition RNA_types.hh:308
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
bool(*) add_ui_poll(const bContext *C)
Definition BKE_node.hh:341