Blender V4.3
node_shader_bsdf_ray_portal.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_vector.h"
8
10
12{
13 b.add_input<decl::Color>("Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
14 b.add_input<decl::Vector>("Position").hide_value();
15 b.add_input<decl::Vector>("Direction").hide_value();
16 b.add_input<decl::Float>("Weight").available(false);
17 b.add_output<decl::Shader>("BSDF");
18}
19
21 bNode *node,
22 bNodeExecData * /*execdata*/,
23 GPUNodeStack *in,
24 GPUNodeStack *out)
25{
26 if (in[0].link || !is_zero_v3(in[0].vec)) {
28 }
29 return GPU_stack_link(mat, node, "node_bsdf_ray_portal", in, out);
30}
31
33#ifdef WITH_MATERIALX
34{
35 switch (to_type_) {
36 case NodeItem::Type::BSDF: {
37 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
38 /* Returning diffuse node as BSDF component */
39 return create_node("oren_nayar_diffuse_bsdf", NodeItem::Type::BSDF, {{"color", color}});
40 }
41 case NodeItem::Type::SurfaceOpacity: {
42 NodeItem color = get_input_value("Color", NodeItem::Type::Color3);
43 /* Returning: 1 - <average of color components> */
44 return val(1.0f) - color.dotproduct(val(1.0f / 3.0f));
45 }
46 default:
47 break;
48 }
49 return empty();
50}
51#endif
53
54} // namespace blender::nodes::node_shader_bsdf_ray_portal_cc
55
56/* node type definition */
58{
60
61 static blender::bke::bNodeType ntype;
62
65 ntype.declare = file_ns::node_declare;
66 ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_ray_portal;
67 ntype.materialx_fn = file_ns::node_shader_materialx;
68
70}
#define SH_NODE_BSDF_RAY_PORTAL
Definition BKE_node.hh:997
#define NODE_CLASS_SHADER
Definition BKE_node.hh:417
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
@ GPU_MATFLAG_TRANSPARENT
void GPU_material_flag_set(GPUMaterial *mat, eGPUMaterialFlag flag)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static int node_shader_gpu_bsdf_ray_portal(GPUMaterial *mat, bNode *node, bNodeExecData *, GPUNodeStack *in, GPUNodeStack *out)
static void node_declare(NodeDeclarationBuilder &b)
#define NODE_SHADER_MATERIALX_BEGIN
#define NODE_SHADER_MATERIALX_END
void register_node_type_sh_bsdf_ray_portal()
void sh_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
bool object_shader_nodes_poll(const bContext *C)
Defines a node type.
Definition BKE_node.hh:218
NodeMaterialXFunction materialx_fn
Definition BKE_node.hh:320
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