Blender  V3.3
node_composite_tonemap.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2006 Blender Foundation. All rights reserved. */
3 
8 #include "RNA_access.h"
9 
10 #include "UI_interface.h"
11 #include "UI_resources.h"
12 
13 #include "node_composite_util.hh"
14 
16 
18 {
19  b.add_input<decl::Color>(N_("Image")).default_value({1.0f, 1.0f, 1.0f, 1.0f});
20  b.add_output<decl::Color>(N_("Image"));
21 }
22 
24 {
25  NodeTonemap *ntm = MEM_cnew<NodeTonemap>(__func__);
26  ntm->type = 1;
27  ntm->key = 0.18;
28  ntm->offset = 1;
29  ntm->gamma = 1;
30  ntm->f = 0;
31  ntm->m = 0; /* Actual value is set according to input. */
32  /* Default a of 1 works well with natural HDR images, but not always so for CGI.
33  * Maybe should use 0 or at least lower initial value instead. */
34  ntm->a = 1;
35  ntm->c = 0;
36  node->storage = ntm;
37 }
38 
40 {
41  uiLayout *col;
42 
43  col = uiLayoutColumn(layout, false);
44  uiItemR(col, ptr, "tonemap_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
45  if (RNA_enum_get(ptr, "tonemap_type") == 0) {
46  uiItemR(col, ptr, "key", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
47  uiItemR(col, ptr, "offset", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
48  uiItemR(col, ptr, "gamma", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
49  }
50  else {
51  uiItemR(col, ptr, "intensity", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
52  uiItemR(
53  col, ptr, "contrast", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
54  uiItemR(
55  col, ptr, "adaptation", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
56  uiItemR(
57  col, ptr, "correction", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
58  }
59 }
60 
61 } // namespace blender::nodes::node_composite_tonemap_cc
62 
64 {
66 
67  static bNodeType ntype;
68 
74 
75  nodeRegisterType(&ntype);
76 }
#define CMP_NODE_TONEMAP
Definition: BKE_node.h:1273
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
Definition: node.cc:4390
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
Definition: node.cc:4426
#define NODE_CLASS_OP_COLOR
Definition: BKE_node.h:347
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
#define UNUSED(x)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
@ UI_ITEM_R_SLIDER
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
OperationNode * node
bNodeTree * ntree
uint col
static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode *node)
static void cmp_node_tonemap_declare(NodeDeclarationBuilder &b)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_cmp_tonemap()
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
Definition: node_util.c:55
void node_free_standard_storage(bNode *node)
Definition: node_util.c:43
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
Defines a node type.
Definition: BKE_node.h:226
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
Definition: BKE_node.h:244
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)
PointerRNA * ptr
Definition: wm_files.c:3480