Blender V4.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
5#include "node_shader_util.hh"
6
8
10{
11 b.add_input<decl::Color>("Base Color").default_value({0.8f, 0.8f, 0.8f, 1.0f});
12 b.add_input<decl::Color>("Specular").default_value({0.03f, 0.03f, 0.03f, 1.0f});
13 b.add_input<decl::Float>("Roughness")
14 .default_value(0.2f)
15 .min(0.0f)
16 .max(1.0f)
18 b.add_input<decl::Color>("Emissive Color").default_value({0.0f, 0.0f, 0.0f, 1.0f});
19 b.add_input<decl::Float>("Transparency")
20 .default_value(0.0f)
21 .min(0.0f)
22 .max(1.0f)
24 b.add_input<decl::Vector>("Normal").hide_value();
25 b.add_input<decl::Float>("Clear Coat")
26 .default_value(0.0f)
27 .min(0.0f)
28 .max(1.0f)
30 b.add_input<decl::Float>("Clear Coat Roughness")
31 .default_value(0.0f)
32 .min(0.0f)
33 .max(1.0f)
35 b.add_input<decl::Vector>("Clear Coat Normal").hide_value();
36 b.add_input<decl::Float>("Weight").available(false);
37 b.add_output<decl::Shader>("BSDF");
38}
39
40#define socket_not_zero(sock) (in[sock].link || (clamp_f(in[sock].vec[0], 0.0f, 1.0f) > 1e-5f))
41
43 bNode *node,
44 bNodeExecData * /*execdata*/,
45 GPUNodeStack *in,
46 GPUNodeStack *out)
47{
48 /* Normals */
49 if (!in[5].link) {
50 GPU_link(mat, "world_normals_get", &in[5].link);
51 }
52
53 /* Coat Normals */
54 if (!in[8].link) {
55 GPU_link(mat, "world_normals_get", &in[8].link);
56 }
57
58 bool use_transparency = socket_not_zero(4);
59 bool use_coat = socket_not_zero(6);
60
62 if (use_coat) {
64 }
65 if (use_transparency) {
67 }
68
70
71 float use_coat_f = use_coat ? 1.0f : 0.0f;
72 return GPU_stack_link(mat, node, "node_eevee_specular", in, out, GPU_constant(&use_coat_f));
73}
74
75} // namespace blender::nodes::node_shader_eevee_specular_cc
76
77/* node type definition */
79{
81
82 static blender::bke::bNodeType ntype;
83
85 ntype.declare = file_ns::node_declare;
87 ntype.gpu_fn = file_ns::node_shader_gpu_eevee_specular;
88
90}
#define SH_NODE_EEVEE_SPECULAR
Definition BKE_node.hh:978
#define NODE_CLASS_SHADER
Definition BKE_node.hh:417
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_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:154
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
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, int type, const char *name, short nclass)
bool object_eevee_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:218
bool(* add_ui_poll)(const bContext *C)
Definition BKE_node.hh:288
NodeGPUExecFunction gpu_fn
Definition BKE_node.hh:318
NodeDeclareFunction declare
Definition BKE_node.hh:347
uint8_t flag
Definition wm_window.cc:138