Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/node.cc2
-rw-r--r--source/blender/nodes/NOD_shader.h2
-rw-r--r--source/blender/nodes/shader/CMakeLists.txt20
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_color_ramp.cc (renamed from source/blender/nodes/shader/nodes/node_shader_valToRgb.cc)96
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc (renamed from source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc)57
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_combine_rgb.cc86
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_combine_xyz.cc67
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc (renamed from source/blender/nodes/shader/nodes/node_shader_mixRgb.cc)6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc74
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_separate_hsv.cc75
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_separate_rgb.cc (renamed from source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc)66
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_separate_xyz.cc (renamed from source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc)47
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc (renamed from source/blender/nodes/shader/nodes/node_shader_shaderToRgb.cc)6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc (renamed from source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.cc)6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_transform.cc (renamed from source/blender/nodes/shader/nodes/node_shader_vectTransform.cc)6
15 files changed, 364 insertions, 252 deletions
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 6558ad894b8..a4f28c103a7 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -5686,7 +5686,7 @@ static void registerShaderNodes()
register_node_type_sh_wavelength();
register_node_type_sh_blackbody();
register_node_type_sh_mix_rgb();
- register_node_type_sh_valtorgb();
+ register_node_type_sh_color_ramp();
register_node_type_sh_rgbtobw();
register_node_type_sh_shadertorgb();
register_node_type_sh_normal();
diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h
index 76c174201e8..74933e69ab2 100644
--- a/source/blender/nodes/NOD_shader.h
+++ b/source/blender/nodes/NOD_shader.h
@@ -42,7 +42,7 @@ void register_node_type_sh_camera(void);
void register_node_type_sh_value(void);
void register_node_type_sh_rgb(void);
void register_node_type_sh_mix_rgb(void);
-void register_node_type_sh_valtorgb(void);
+void register_node_type_sh_color_ramp(void);
void register_node_type_sh_rgbtobw(void);
void register_node_type_sh_shadertorgb(void);
void register_node_type_sh_normal(void);
diff --git a/source/blender/nodes/shader/CMakeLists.txt b/source/blender/nodes/shader/CMakeLists.txt
index b582960f03f..bdbdef6e9ec 100644
--- a/source/blender/nodes/shader/CMakeLists.txt
+++ b/source/blender/nodes/shader/CMakeLists.txt
@@ -59,6 +59,10 @@ set(SRC
nodes/node_shader_bump.cc
nodes/node_shader_camera.cc
nodes/node_shader_clamp.cc
+ nodes/node_shader_color_ramp.cc
+ nodes/node_shader_combine_hsv.cc
+ nodes/node_shader_combine_rgb.cc
+ nodes/node_shader_combine_xyz.cc
nodes/node_shader_common.cc
nodes/node_shader_curves.cc
nodes/node_shader_displacement.cc
@@ -78,7 +82,7 @@ set(SRC
nodes/node_shader_map_range.cc
nodes/node_shader_mapping.cc
nodes/node_shader_math.cc
- nodes/node_shader_mixRgb.cc
+ nodes/node_shader_mix_rgb.cc
nodes/node_shader_mix_shader.cc
nodes/node_shader_normal.cc
nodes/node_shader_normal_map.cc
@@ -90,11 +94,12 @@ set(SRC
nodes/node_shader_output_world.cc
nodes/node_shader_particle_info.cc
nodes/node_shader_rgb.cc
+ nodes/node_shader_rgb_to_bw.cc
nodes/node_shader_script.cc
- nodes/node_shader_sepcombHSV.cc
- nodes/node_shader_sepcombRGB.cc
- nodes/node_shader_sepcombXYZ.cc
- nodes/node_shader_shaderToRgb.cc
+ nodes/node_shader_separate_hsv.cc
+ nodes/node_shader_separate_rgb.cc
+ nodes/node_shader_separate_xyz.cc
+ nodes/node_shader_shader_to_rgb.cc
nodes/node_shader_squeeze.cc
nodes/node_shader_subsurface_scattering.cc
nodes/node_shader_tangent.cc
@@ -112,14 +117,13 @@ set(SRC
nodes/node_shader_tex_voronoi.cc
nodes/node_shader_tex_wave.cc
nodes/node_shader_tex_white_noise.cc
- nodes/node_shader_uvAlongStroke.cc
+ nodes/node_shader_uv_along_stroke.cc
nodes/node_shader_uvmap.cc
- nodes/node_shader_valToRgb.cc
nodes/node_shader_value.cc
- nodes/node_shader_vectTransform.cc
nodes/node_shader_vector_displacement.cc
nodes/node_shader_vector_math.cc
nodes/node_shader_vector_rotate.cc
+ nodes/node_shader_vector_transform.cc
nodes/node_shader_vertex_color.cc
nodes/node_shader_volume_absorption.cc
nodes/node_shader_volume_info.cc
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
index b65269f8e35..2bb3f2e08cf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc
@@ -13,7 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
* All rights reserved.
*/
@@ -21,17 +21,15 @@
* \ingroup shdnodes
*/
-#include "IMB_colormanagement.h"
-
#include "DNA_texture_types.h"
#include "BLI_color.hh"
#include "node_shader_util.hh"
-namespace blender::nodes::node_shader_valToRgb_cc {
+namespace blender::nodes::node_shader_color_ramp_cc {
-static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b)
+static void sh_node_color_ramp_declare(NodeDeclarationBuilder &b)
{
b.is_function_node();
b.add_input<decl::Float>(N_("Fac")).default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
@@ -39,12 +37,12 @@ static void sh_node_valtorgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Alpha"));
};
-static void node_shader_exec_valtorgb(void *UNUSED(data),
- int UNUSED(thread),
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- bNodeStack **in,
- bNodeStack **out)
+static void node_shader_exec_color_ramp(void *UNUSED(data),
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **in,
+ bNodeStack **out)
{
/* stack order in: fac */
/* stack order out: col, alpha */
@@ -58,16 +56,16 @@ static void node_shader_exec_valtorgb(void *UNUSED(data),
}
}
-static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_shader_init_color_ramp(bNodeTree *UNUSED(ntree), bNode *node)
{
node->storage = BKE_colorband_add(true);
}
-static int gpu_shader_valtorgb(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
+static int gpu_shader_color_ramp(GPUMaterial *mat,
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ GPUNodeStack *in,
+ GPUNodeStack *out)
{
struct ColorBand *coba = (ColorBand *)node->storage;
float *array, layer;
@@ -162,7 +160,7 @@ class ColorBandFunction : public blender::fn::MultiFunction {
}
};
-static void sh_node_valtorgb_build_multi_function(
+static void sh_node_color_ramp_build_multi_function(
blender::nodes::NodeMultiFunctionBuilder &builder)
{
bNode &bnode = builder.node();
@@ -170,66 +168,22 @@ static void sh_node_valtorgb_build_multi_function(
builder.construct_and_set_matching_fn<ColorBandFunction>(*color_band);
}
-static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
-{
- b.add_input<decl::Color>(N_("Color")).default_value({0.5f, 0.5f, 0.5f, 1.0f});
- b.add_output<decl::Float>(N_("Val"));
-};
-
-static void node_shader_exec_rgbtobw(void *UNUSED(data),
- int UNUSED(thread),
- bNode *UNUSED(node),
- bNodeExecData *UNUSED(execdata),
- bNodeStack **in,
- bNodeStack **out)
-{
- /* Stack order out: BW. */
- /* Stack order in: COL. */
- float col[3];
- nodestack_get_vec(col, SOCK_VECTOR, in[0]);
-
- out[0]->vec[0] = IMB_colormanagement_get_luminance(col);
-}
-
-static int gpu_shader_rgbtobw(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
-{
- return GPU_stack_link(mat, node, "rgbtobw", in, out);
-}
-
-} // namespace blender::nodes::node_shader_valToRgb_cc
+} // namespace blender::nodes::node_shader_color_ramp_cc
-void register_node_type_sh_valtorgb()
+void register_node_type_sh_color_ramp()
{
- namespace file_ns = blender::nodes::node_shader_valToRgb_cc;
+ namespace file_ns = blender::nodes::node_shader_color_ramp_cc;
static bNodeType ntype;
sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER, 0);
- ntype.declare = file_ns::sh_node_valtorgb_declare;
- node_type_init(&ntype, file_ns::node_shader_init_valtorgb);
+ ntype.declare = file_ns::sh_node_color_ramp_declare;
+ node_type_init(&ntype, file_ns::node_shader_init_color_ramp);
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
- node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_valtorgb);
- node_type_gpu(&ntype, file_ns::gpu_shader_valtorgb);
- ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function;
-
- nodeRegisterType(&ntype);
-}
-
-void register_node_type_sh_rgbtobw()
-{
- namespace file_ns = blender::nodes::node_shader_valToRgb_cc;
-
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER, 0);
- ntype.declare = file_ns::sh_node_rgbtobw_declare;
- node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_rgbtobw);
- node_type_gpu(&ntype, file_ns::gpu_shader_rgbtobw);
+ node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_color_ramp);
+ node_type_gpu(&ntype, file_ns::gpu_shader_color_ramp);
+ ntype.build_multi_function = file_ns::sh_node_color_ramp_build_multi_function;
nodeRegisterType(&ntype);
-}
+} \ No newline at end of file
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc b/source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc
index b47c98fadec..4d4879fd060 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombHSV.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_combine_hsv.cc
@@ -23,44 +23,7 @@
#include "node_shader_util.hh"
-/* **************** SEPARATE HSV ******************** */
-
-namespace blender::nodes::node_shader_sepcombHSV_cc {
-
-static bNodeSocketTemplate sh_node_sephsv_in[] = {
- {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f},
- {-1, ""},
-};
-static bNodeSocketTemplate sh_node_sephsv_out[] = {
- {SOCK_FLOAT, N_("H")},
- {SOCK_FLOAT, N_("S")},
- {SOCK_FLOAT, N_("V")},
- {-1, ""},
-};
-
-static void node_shader_exec_sephsv(void *UNUSED(data),
- int UNUSED(thread),
- bNode *UNUSED(node),
- bNodeExecData *UNUSED(execdata),
- bNodeStack **in,
- bNodeStack **out)
-{
- float col[3];
- nodestack_get_vec(col, SOCK_VECTOR, in[0]);
-
- rgb_to_hsv(col[0], col[1], col[2], &out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
-}
-
-static int gpu_shader_sephsv(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
-{
- return GPU_stack_link(mat, node, "separate_hsv", in, out);
-}
-
-/* **************** COMBINE HSV ******************** */
+namespace blender::nodes::node_shader_combine_hsv_cc {
static bNodeSocketTemplate sh_node_combhsv_in[] = {
{SOCK_FLOAT, N_("H"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED},
@@ -97,25 +60,11 @@ static int gpu_shader_combhsv(GPUMaterial *mat,
return GPU_stack_link(mat, node, "combine_hsv", in, out);
}
-} // namespace blender::nodes::node_shader_sepcombHSV_cc
-
-void register_node_type_sh_sephsv()
-{
- namespace file_ns = blender::nodes::node_shader_sepcombHSV_cc;
-
- static bNodeType ntype;
-
- sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTER, 0);
- node_type_socket_templates(&ntype, file_ns::sh_node_sephsv_in, file_ns::sh_node_sephsv_out);
- node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_sephsv);
- node_type_gpu(&ntype, file_ns::gpu_shader_sephsv);
-
- nodeRegisterType(&ntype);
-}
+} // namespace blender::nodes::node_shader_combine_hsv_cc
void register_node_type_sh_combhsv()
{
- namespace file_ns = blender::nodes::node_shader_sepcombHSV_cc;
+ namespace file_ns = blender::nodes::node_shader_combine_hsv_cc;
static bNodeType ntype;
diff --git a/source/blender/nodes/shader/nodes/node_shader_combine_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_combine_rgb.cc
new file mode 100644
index 00000000000..f5d401a5044
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_combine_rgb.cc
@@ -0,0 +1,86 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup shdnodes
+ */
+
+#include "node_shader_util.hh"
+
+namespace blender::nodes::node_shader_combine_rgb_cc {
+
+static void sh_node_combrgb_declare(NodeDeclarationBuilder &b)
+{
+ b.is_function_node();
+ b.add_input<decl::Float>(N_("R")).min(0.0f).max(1.0f);
+ b.add_input<decl::Float>(N_("G")).min(0.0f).max(1.0f);
+ b.add_input<decl::Float>(N_("B")).min(0.0f).max(1.0f);
+ b.add_output<decl::Color>(N_("Image"));
+};
+
+static void node_shader_exec_combrgb(void *UNUSED(data),
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **in,
+ bNodeStack **out)
+{
+ float r, g, b;
+ nodestack_get_vec(&r, SOCK_FLOAT, in[0]);
+ nodestack_get_vec(&g, SOCK_FLOAT, in[1]);
+ nodestack_get_vec(&b, SOCK_FLOAT, in[2]);
+
+ out[0]->vec[0] = r;
+ out[0]->vec[1] = g;
+ out[0]->vec[2] = b;
+}
+
+static int gpu_shader_combrgb(GPUMaterial *mat,
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ GPUNodeStack *in,
+ GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, node, "combine_rgb", in, out);
+}
+
+static void sh_node_combrgb_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
+{
+ static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::ColorGeometry4f> fn{
+ "Combine RGB",
+ [](float r, float g, float b) { return blender::ColorGeometry4f(r, g, b, 1.0f); }};
+ builder.set_matching_fn(fn);
+}
+
+} // namespace blender::nodes::node_shader_combine_rgb_cc
+
+void register_node_type_sh_combrgb()
+{
+ namespace file_ns = blender::nodes::node_shader_combine_rgb_cc;
+
+ static bNodeType ntype;
+
+ sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTER, 0);
+ ntype.declare = file_ns::sh_node_combrgb_declare;
+ node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_combrgb);
+ node_type_gpu(&ntype, file_ns::gpu_shader_combrgb);
+ ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
+
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_combine_xyz.cc b/source/blender/nodes/shader/nodes/node_shader_combine_xyz.cc
new file mode 100644
index 00000000000..ff5b333a459
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_combine_xyz.cc
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2014 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup shdnodes
+ */
+
+#include "node_shader_util.hh"
+
+namespace blender::nodes::node_shader_combine_xyz_cc {
+
+static void sh_node_combxyz_declare(NodeDeclarationBuilder &b)
+{
+ b.is_function_node();
+ b.add_input<decl::Float>(N_("X")).min(-10000.0f).max(10000.0f);
+ b.add_input<decl::Float>(N_("Y")).min(-10000.0f).max(10000.0f);
+ b.add_input<decl::Float>(N_("Z")).min(-10000.0f).max(10000.0f);
+ b.add_output<decl::Vector>(N_("Vector"));
+};
+
+static int gpu_shader_combxyz(GPUMaterial *mat,
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ GPUNodeStack *in,
+ GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, node, "combine_xyz", in, out);
+}
+
+static void sh_node_combxyz_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
+{
+ static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::float3> fn{
+ "Combine Vector", [](float x, float y, float z) { return blender::float3(x, y, z); }};
+ builder.set_matching_fn(fn);
+}
+
+} // namespace blender::nodes::node_shader_combine_xyz_cc
+
+void register_node_type_sh_combxyz()
+{
+ namespace file_ns = blender::nodes::node_shader_combine_xyz_cc;
+
+ static bNodeType ntype;
+
+ sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTER, 0);
+ ntype.declare = file_ns::sh_node_combxyz_declare;
+ node_type_gpu(&ntype, file_ns::gpu_shader_combxyz);
+ ntype.build_multi_function = file_ns::sh_node_combxyz_build_multi_function;
+
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.cc b/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc
index c41bd438084..288161d1463 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc
@@ -23,7 +23,7 @@
#include "node_shader_util.hh"
-namespace blender::nodes::node_shader_mixRgb_cc {
+namespace blender::nodes::node_shader_mix_rgb_cc {
static void sh_node_mix_rgb_declare(NodeDeclarationBuilder &b)
{
@@ -181,11 +181,11 @@ static void sh_node_mix_rgb_build_multi_function(blender::nodes::NodeMultiFuncti
builder.construct_and_set_matching_fn<MixRGBFunction>(clamp, mix_type);
}
-} // namespace blender::nodes::node_shader_mixRgb_cc
+} // namespace blender::nodes::node_shader_mix_rgb_cc
void register_node_type_sh_mix_rgb()
{
- namespace file_ns = blender::nodes::node_shader_mixRgb_cc;
+ namespace file_ns = blender::nodes::node_shader_mix_rgb_cc;
static bNodeType ntype;
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc b/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc
new file mode 100644
index 00000000000..7d6fec4b7c5
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc
@@ -0,0 +1,74 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup shdnodes
+ */
+
+#include "IMB_colormanagement.h"
+
+#include "node_shader_util.hh"
+
+namespace blender::nodes::node_shader_rgb_to_bw_cc {
+
+static void sh_node_rgbtobw_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Color>(N_("Color")).default_value({0.5f, 0.5f, 0.5f, 1.0f});
+ b.add_output<decl::Float>(N_("Val"));
+};
+
+static void node_shader_exec_rgbtobw(void *UNUSED(data),
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **in,
+ bNodeStack **out)
+{
+ /* Stack order out: BW. */
+ /* Stack order in: COL. */
+ float col[3];
+ nodestack_get_vec(col, SOCK_VECTOR, in[0]);
+
+ out[0]->vec[0] = IMB_colormanagement_get_luminance(col);
+}
+
+static int gpu_shader_rgbtobw(GPUMaterial *mat,
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ GPUNodeStack *in,
+ GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, node, "rgbtobw", in, out);
+}
+
+} // namespace blender::nodes::node_shader_rgb_to_bw_cc
+
+void register_node_type_sh_rgbtobw()
+{
+ namespace file_ns = blender::nodes::node_shader_rgb_to_bw_cc;
+
+ static bNodeType ntype;
+
+ sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER, 0);
+ ntype.declare = file_ns::sh_node_rgbtobw_declare;
+ node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_rgbtobw);
+ node_type_gpu(&ntype, file_ns::gpu_shader_rgbtobw);
+
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_separate_hsv.cc b/source/blender/nodes/shader/nodes/node_shader_separate_hsv.cc
new file mode 100644
index 00000000000..242bc5f9781
--- /dev/null
+++ b/source/blender/nodes/shader/nodes/node_shader_separate_hsv.cc
@@ -0,0 +1,75 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup shdnodes
+ */
+
+#include "node_shader_util.hh"
+
+namespace blender::nodes::node_shader_separate_hsv_cc {
+
+static bNodeSocketTemplate sh_node_sephsv_in[] = {
+ {SOCK_RGBA, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f},
+ {-1, ""},
+};
+static bNodeSocketTemplate sh_node_sephsv_out[] = {
+ {SOCK_FLOAT, N_("H")},
+ {SOCK_FLOAT, N_("S")},
+ {SOCK_FLOAT, N_("V")},
+ {-1, ""},
+};
+
+static void node_shader_exec_sephsv(void *UNUSED(data),
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *UNUSED(execdata),
+ bNodeStack **in,
+ bNodeStack **out)
+{
+ float col[3];
+ nodestack_get_vec(col, SOCK_VECTOR, in[0]);
+
+ rgb_to_hsv(col[0], col[1], col[2], &out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
+}
+
+static int gpu_shader_sephsv(GPUMaterial *mat,
+ bNode *node,
+ bNodeExecData *UNUSED(execdata),
+ GPUNodeStack *in,
+ GPUNodeStack *out)
+{
+ return GPU_stack_link(mat, node, "separate_hsv", in, out);
+}
+
+} // namespace blender::nodes::node_shader_separate_hsv_cc
+
+void register_node_type_sh_sephsv()
+{
+ namespace file_ns = blender::nodes::node_shader_separate_hsv_cc;
+
+ static bNodeType ntype;
+
+ sh_node_type_base(&ntype, SH_NODE_SEPHSV, "Separate HSV", NODE_CLASS_CONVERTER, 0);
+ node_type_socket_templates(&ntype, file_ns::sh_node_sephsv_in, file_ns::sh_node_sephsv_out);
+ node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_sephsv);
+ node_type_gpu(&ntype, file_ns::gpu_shader_sephsv);
+
+ nodeRegisterType(&ntype);
+}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc b/source/blender/nodes/shader/nodes/node_shader_separate_rgb.cc
index 0b8c8ad443d..2f57fe31f47 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_separate_rgb.cc
@@ -13,7 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
* All rights reserved.
*/
@@ -23,7 +23,7 @@
#include "node_shader_util.hh"
-namespace blender::nodes::node_shader_sepcombRGB_cc {
+namespace blender::nodes::node_shader_separate_rgb_cc {
static void sh_node_seprgb_declare(NodeDeclarationBuilder &b)
{
@@ -101,54 +101,11 @@ static void sh_node_seprgb_build_multi_function(blender::nodes::NodeMultiFunctio
builder.set_matching_fn(fn);
}
-static void sh_node_combrgb_declare(NodeDeclarationBuilder &b)
-{
- b.is_function_node();
- b.add_input<decl::Float>(N_("R")).min(0.0f).max(1.0f);
- b.add_input<decl::Float>(N_("G")).min(0.0f).max(1.0f);
- b.add_input<decl::Float>(N_("B")).min(0.0f).max(1.0f);
- b.add_output<decl::Color>(N_("Image"));
-};
-
-static void node_shader_exec_combrgb(void *UNUSED(data),
- int UNUSED(thread),
- bNode *UNUSED(node),
- bNodeExecData *UNUSED(execdata),
- bNodeStack **in,
- bNodeStack **out)
-{
- float r, g, b;
- nodestack_get_vec(&r, SOCK_FLOAT, in[0]);
- nodestack_get_vec(&g, SOCK_FLOAT, in[1]);
- nodestack_get_vec(&b, SOCK_FLOAT, in[2]);
-
- out[0]->vec[0] = r;
- out[0]->vec[1] = g;
- out[0]->vec[2] = b;
-}
-
-static int gpu_shader_combrgb(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
-{
- return GPU_stack_link(mat, node, "combine_rgb", in, out);
-}
-
-static void sh_node_combrgb_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
-{
- static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::ColorGeometry4f> fn{
- "Combine RGB",
- [](float r, float g, float b) { return blender::ColorGeometry4f(r, g, b, 1.0f); }};
- builder.set_matching_fn(fn);
-}
-
-} // namespace blender::nodes::node_shader_sepcombRGB_cc
+} // namespace blender::nodes::node_shader_separate_rgb_cc
void register_node_type_sh_seprgb()
{
- namespace file_ns = blender::nodes::node_shader_sepcombRGB_cc;
+ namespace file_ns = blender::nodes::node_shader_separate_rgb_cc;
static bNodeType ntype;
@@ -160,18 +117,3 @@ void register_node_type_sh_seprgb()
nodeRegisterType(&ntype);
}
-
-void register_node_type_sh_combrgb()
-{
- namespace file_ns = blender::nodes::node_shader_sepcombRGB_cc;
-
- static bNodeType ntype;
-
- sh_fn_node_type_base(&ntype, SH_NODE_COMBRGB, "Combine RGB", NODE_CLASS_CONVERTER, 0);
- ntype.declare = file_ns::sh_node_combrgb_declare;
- node_type_exec(&ntype, nullptr, nullptr, file_ns::node_shader_exec_combrgb);
- node_type_gpu(&ntype, file_ns::gpu_shader_combrgb);
- ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function;
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc b/source/blender/nodes/shader/nodes/node_shader_separate_xyz.cc
index c5e83789a8e..ee2335978a3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_separate_xyz.cc
@@ -13,7 +13,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2014 Blender Foundation.
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
* All rights reserved.
*/
@@ -23,7 +23,7 @@
#include "node_shader_util.hh"
-namespace blender::nodes::node_shader_sepcombXYZ_cc {
+namespace blender::nodes::node_shader_separate_xyz_cc {
static void sh_node_sepxyz_declare(NodeDeclarationBuilder &b)
{
@@ -86,36 +86,11 @@ static void sh_node_sepxyz_build_multi_function(blender::nodes::NodeMultiFunctio
builder.set_matching_fn(separate_fn);
}
-static void sh_node_combxyz_declare(NodeDeclarationBuilder &b)
-{
- b.is_function_node();
- b.add_input<decl::Float>(N_("X")).min(-10000.0f).max(10000.0f);
- b.add_input<decl::Float>(N_("Y")).min(-10000.0f).max(10000.0f);
- b.add_input<decl::Float>(N_("Z")).min(-10000.0f).max(10000.0f);
- b.add_output<decl::Vector>(N_("Vector"));
-};
-
-static int gpu_shader_combxyz(GPUMaterial *mat,
- bNode *node,
- bNodeExecData *UNUSED(execdata),
- GPUNodeStack *in,
- GPUNodeStack *out)
-{
- return GPU_stack_link(mat, node, "combine_xyz", in, out);
-}
-
-static void sh_node_combxyz_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
-{
- static blender::fn::CustomMF_SI_SI_SI_SO<float, float, float, blender::float3> fn{
- "Combine Vector", [](float x, float y, float z) { return blender::float3(x, y, z); }};
- builder.set_matching_fn(fn);
-}
-
-} // namespace blender::nodes::node_shader_sepcombXYZ_cc
+} // namespace blender::nodes::node_shader_separate_xyz_cc
void register_node_type_sh_sepxyz()
{
- namespace file_ns = blender::nodes::node_shader_sepcombXYZ_cc;
+ namespace file_ns = blender::nodes::node_shader_separate_xyz_cc;
static bNodeType ntype;
@@ -126,17 +101,3 @@ void register_node_type_sh_sepxyz()
nodeRegisterType(&ntype);
}
-
-void register_node_type_sh_combxyz()
-{
- namespace file_ns = blender::nodes::node_shader_sepcombXYZ_cc;
-
- static bNodeType ntype;
-
- sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTER, 0);
- ntype.declare = file_ns::sh_node_combxyz_declare;
- node_type_gpu(&ntype, file_ns::gpu_shader_combxyz);
- ntype.build_multi_function = file_ns::sh_node_combxyz_build_multi_function;
-
- nodeRegisterType(&ntype);
-}
diff --git a/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.cc b/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc
index 69b1099a76a..3791eb9449f 100644
--- a/source/blender/nodes/shader/nodes/node_shader_shaderToRgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc
@@ -21,7 +21,7 @@
/* **************** OUTPUT ******************** */
-namespace blender::nodes::node_shader_shaderToRgb_cc {
+namespace blender::nodes::node_shader_shader_to_rgb_cc {
static bNodeSocketTemplate sh_node_shadertorgb_in[] = {
{SOCK_SHADER, N_("Shader")},
@@ -47,12 +47,12 @@ static int node_shader_gpu_shadertorgb(GPUMaterial *mat,
return GPU_stack_link(mat, node, "node_shader_to_rgba", in, out);
}
-} // namespace blender::nodes::node_shader_shaderToRgb_cc
+} // namespace blender::nodes::node_shader_shader_to_rgb_cc
/* node type definition */
void register_node_type_sh_shadertorgb()
{
- namespace file_ns = blender::nodes::node_shader_shaderToRgb_cc;
+ namespace file_ns = blender::nodes::node_shader_shader_to_rgb_cc;
static bNodeType ntype;
diff --git a/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.cc b/source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc
index cdcb5f34bb9..8cb60199581 100644
--- a/source/blender/nodes/shader/nodes/node_shader_uvAlongStroke.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_uv_along_stroke.cc
@@ -21,19 +21,19 @@
/* **************** OUTPUT ******************** */
-namespace blender::nodes::node_shader_uvAlongStroke_cc {
+namespace blender::nodes::node_shader_uv_along_stroke_cc {
static bNodeSocketTemplate sh_node_uvalongstroke_out[] = {
{SOCK_VECTOR, N_("UV"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{-1, ""},
};
-} // namespace blender::nodes::node_shader_uvAlongStroke_cc
+} // namespace blender::nodes::node_shader_uv_along_stroke_cc
/* node type definition */
void register_node_type_sh_uvalongstroke()
{
- namespace file_ns = blender::nodes::node_shader_uvAlongStroke_cc;
+ namespace file_ns = blender::nodes::node_shader_uv_along_stroke_cc;
static bNodeType ntype;
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.cc b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc
index bfaca357c5c..d354b579c36 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc
@@ -25,7 +25,7 @@
/* **************** Vector Transform ******************** */
-namespace blender::nodes::node_shader_vectTransform_cc {
+namespace blender::nodes::node_shader_vector_transform_cc {
static bNodeSocketTemplate sh_node_vect_transform_in[] = {
{SOCK_VECTOR, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, {-1, ""}};
@@ -140,11 +140,11 @@ static int gpu_shader_vect_transform(GPUMaterial *mat,
return true;
}
-} // namespace blender::nodes::node_shader_vectTransform_cc
+} // namespace blender::nodes::node_shader_vector_transform_cc
void register_node_type_sh_vect_transform()
{
- namespace file_ns = blender::nodes::node_shader_vectTransform_cc;
+ namespace file_ns = blender::nodes::node_shader_vector_transform_cc;
static bNodeType ntype;