Blender V4.3
node_composite_huecorrect.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_colortools.hh"
10
11#include "GPU_material.hh"
12
13#include "COM_shader_node.hh"
14
16
18
20{
21 b.add_input<decl::Float>("Fac")
22 .default_value(1.0f)
23 .min(0.0f)
24 .max(1.0f)
26 .compositor_domain_priority(1);
27 b.add_input<decl::Color>("Image")
28 .default_value({1.0f, 1.0f, 1.0f, 1.0f})
29 .compositor_domain_priority(0);
30 b.add_output<decl::Color>("Image");
31}
32
33static void node_composit_init_huecorrect(bNodeTree * /*ntree*/, bNode *node)
34{
35 node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
36
37 CurveMapping *cumapping = (CurveMapping *)node->storage;
38
39 cumapping->preset = CURVE_PRESET_MID8;
40
41 for (int c = 0; c < 3; c++) {
42 CurveMap *cuma = &cumapping->cm[c];
43 BKE_curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE);
44 }
45 /* use wrapping for all hue correct nodes */
46 cumapping->flag |= CUMA_USE_WRAPPING;
47 /* default to showing Saturation */
48 cumapping->cur = 1;
49}
50
51using namespace blender::realtime_compositor;
52
54 public:
56
57 void compile(GPUMaterial *material) override
58 {
61
62 CurveMapping *curve_mapping = const_cast<CurveMapping *>(get_curve_mapping());
63
64 BKE_curvemapping_init(curve_mapping);
65 float *band_values;
66 int band_size;
67 BKE_curvemapping_table_RGBA(curve_mapping, &band_values, &band_size);
68 float band_layer;
69 GPUNodeLink *band_texture = GPU_color_band(material, band_size, band_values, &band_layer);
70
71 float range_minimums[CM_TOT];
72 BKE_curvemapping_get_range_minimums(curve_mapping, range_minimums);
73 float range_dividers[CM_TOT];
74 BKE_curvemapping_compute_range_dividers(curve_mapping, range_dividers);
75
76 GPU_stack_link(material,
77 &bnode(),
78 "node_composite_hue_correct",
79 inputs,
80 outputs,
81 band_texture,
82 GPU_constant(&band_layer),
83 GPU_uniform(range_minimums),
84 GPU_uniform(range_dividers));
85 }
86
88 {
89 return static_cast<const CurveMapping *>(bnode().storage);
90 }
91};
92
94{
95 return new HueCorrectShaderNode(node);
96}
97
98} // namespace blender::nodes::node_composite_huecorrect_cc
99
101{
103
104 static blender::bke::bNodeType ntype;
105
106 cmp_node_type_base(&ntype, CMP_NODE_HUECORRECT, "Hue Correct", NODE_CLASS_OP_COLOR);
107 ntype.declare = file_ns::cmp_node_huecorrect_declare;
108 blender::bke::node_type_size(&ntype, 320, 140, 500);
109 ntype.initfunc = file_ns::node_composit_init_huecorrect;
111 ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
112
114}
@ CURVEMAP_SLOPE_POSITIVE
void BKE_curvemapping_compute_range_dividers(const CurveMapping *curve_mapping, float dividers[4])
void BKE_curvemapping_get_range_minimums(const CurveMapping *curve_mapping, float minimums[4])
void BKE_curvemapping_init(CurveMapping *cumap)
CurveMapping * BKE_curvemapping_add(int tot, float minx, float miny, float maxx, float maxy)
Definition colortools.cc:90
void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope)
void BKE_curvemapping_table_RGBA(const CurveMapping *cumap, float **array, int *size)
#define NODE_CLASS_OP_COLOR
Definition BKE_node.hh:406
#define CM_TOT
@ CUMA_USE_WRAPPING
@ CURVE_PRESET_MID8
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
GPUNodeLink * GPU_constant(const float *num)
GPUNodeLink * GPU_color_band(GPUMaterial *mat, int size, float *pixels, float *r_row)
GPUNodeLink * GPU_uniform(const float *num)
@ PROP_FACTOR
Definition RNA_types.hh:154
local_group_size(16, 16) .push_constant(Type b
void node_type_size(bNodeType *ntype, int width, int minwidth, int maxwidth)
Definition node.cc:4602
void node_type_storage(bNodeType *ntype, const char *storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
Definition node.cc:4632
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static ShaderNode * get_compositor_shader_node(DNode node)
static void node_composit_init_huecorrect(bNodeTree *, bNode *node)
static void cmp_node_huecorrect_declare(NodeDeclarationBuilder &b)
void register_node_type_cmp_huecorrect()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_curves(bNodeTree *, bNode *dest_node, const bNode *src_node)
Definition node_util.cc:53
void node_free_curves(bNode *node)
Definition node_util.cc:41
CurveMap cm[4]
void * storage
Defines a node type.
Definition BKE_node.hh:218
void(* initfunc)(bNodeTree *ntree, bNode *node)
Definition BKE_node.hh:267
NodeDeclareFunction declare
Definition BKE_node.hh:347
NodeGetCompositorShaderNodeFunction get_compositor_shader_node
Definition BKE_node.hh:328