Blender V5.0
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
5#include "node_shader_util.hh"
6
7#include "BLI_math_base.h"
8
10
12{
13 b.add_input<decl::Color>("Base Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
14 b.add_input<decl::Color>("Specular").default_value({0.03f, 0.03f, 0.03f, 1.0f});
15 b.add_input<decl::Float>("Roughness")
16 .default_value(0.2f)
17 .min(0.0f)
18 .max(1.0f)
20 b.add_input<decl::Color>("Emissive Color").default_value({0.0f, 0.0f, 0.0f, 1.0f});
21 b.add_input<decl::Float>("Transparency")
22 .default_value(0.0f)
23 .min(0.0f)
24 .max(1.0f)
26 b.add_input<decl::Vector>("Normal").hide_value();
27 b.add_input<decl::Float>("Clear Coat")
28 .default_value(0.0f)
29 .min(0.0f)
30 .max(1.0f)
32 b.add_input<decl::Float>("Clear Coat Roughness")
33 .default_value(0.0f)
34 .min(0.0f)
35 .max(1.0f)
37 b.add_input<decl::Vector>("Clear Coat Normal").hide_value();
38 b.add_input<decl::Float>("Weight").available(false);
39 b.add_output<decl::Shader>("BSDF");
40}
41
42#define socket_not_zero(sock) (in[sock].link || (clamp_f(in[sock].vec[0], 0.0f, 1.0f) > 1e-5f))
43
45 bNode *node,
46 bNodeExecData * /*execdata*/,
49{
50 /* Normals */
51 if (!in[5].link) {
52 GPU_link(mat, "world_normals_get", &in[5].link);
53 }
54
55 /* Coat Normals */
56 if (!in[8].link) {
57 GPU_link(mat, "world_normals_get", &in[8].link);
58 }
59
60 bool use_transparency = socket_not_zero(4);
61 bool use_coat = socket_not_zero(6);
62
64
65 if (in[1].might_be_tinted()) {
67 }
68 if (use_coat) {
70 }
71 if (use_transparency) {
73 }
74
76
77 float use_coat_f = use_coat ? 1.0f : 0.0f;
78 return GPU_stack_link(mat, node, "node_eevee_specular", in, out, GPU_constant(&use_coat_f));
79}
80
81} // namespace blender::nodes::node_shader_eevee_specular_cc
82
83/* node type definition */
85{
87
88 static blender::bke::bNodeType ntype;
89
90 sh_node_type_base(&ntype, "ShaderNodeEeveeSpecular", SH_NODE_EEVEE_SPECULAR);
91 ntype.ui_name = "Specular BSDF";
92 ntype.ui_description =
93 "Similar to the Principled BSDF node but uses the specular workflow instead of metallic, "
94 "which functions by specifying the facing (along normal) reflection color. Energy is not "
95 "conserved, so the result may not be physically accurate";
96 ntype.enum_name_legacy = "EEVEE_SPECULAR";
98 ntype.declare = file_ns::node_declare;
100 ntype.gpu_fn = file_ns::node_shader_gpu_eevee_specular;
101
103}
#define NODE_CLASS_SHADER
Definition BKE_node.hh:460
#define SH_NODE_EEVEE_SPECULAR
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
eGPUMaterialFlag
@ GPU_MATFLAG_REFLECTION_MAYBE_COLORED
@ GPU_MATFLAG_GLOSSY
@ GPU_MATFLAG_COAT
@ GPU_MATFLAG_DIFFUSE
@ GPU_MATFLAG_TRANSPARENT
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
bool GPU_link(GPUMaterial *mat, const char *name,...)
@ PROP_FACTOR
Definition RNA_types.hh:251
#define in
#define out
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
static int node_shader_gpu_eevee_specular(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
#define socket_not_zero(sock)
void register_node_type_sh_eevee_specular()
void sh_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
bool object_eevee_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:238
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
uint8_t flag
Definition wm_window.cc:145