Created
April 19, 2013 05:25
-
-
Save sobotka/5418323 to your computer and use it in GitHub Desktop.
OCIO patch for a Blender node. Doesn't quite do what is needed, as it adjusts the input image's ImBuf directly. It needs to be an arbitrary application on data so that an artist can control the transformations with granularity and without worrying about the input image's ImBuf space.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: source/blender/blenkernel/BKE_node.h | |
=================================================================== | |
--- source/blender/blenkernel/BKE_node.h (revision 55048) | |
+++ source/blender/blenkernel/BKE_node.h (working copy) | |
@@ -717,6 +717,8 @@ | |
#define CMP_NODE_MAP_RANGE 319 | |
+#define CMP_NODE_COLORSPACETRANSFORM 320 | |
+ | |
/* channel toggles */ | |
#define CMP_CHAN_RGB 1 | |
#define CMP_CHAN_A 2 | |
Index: source/blender/blenkernel/intern/node.c | |
=================================================================== | |
--- source/blender/blenkernel/intern/node.c (revision 55048) | |
+++ source/blender/blenkernel/intern/node.c (working copy) | |
@@ -2295,6 +2295,7 @@ | |
register_node_type_cmp_moviedistortion(ttype); | |
register_node_type_cmp_colorcorrection(ttype); | |
+ register_node_type_cmp_colorspacetransform(ttype); | |
register_node_type_cmp_boxmask(ttype); | |
register_node_type_cmp_ellipsemask(ttype); | |
register_node_type_cmp_bokehimage(ttype); | |
Index: source/blender/compositor/CMakeLists.txt | |
=================================================================== | |
--- source/blender/compositor/CMakeLists.txt (revision 55048) | |
+++ source/blender/compositor/CMakeLists.txt (working copy) | |
@@ -238,6 +238,8 @@ | |
nodes/COM_TonemapNode.h | |
operations/COM_TonemapOperation.cpp | |
operations/COM_TonemapOperation.h | |
+ nodes/COM_ColorSpaceTransformNode.cpp | |
+ nodes/COM_ColorSpaceTransformNode.h | |
# converter nodes | |
nodes/COM_IDMaskNode.cpp | |
@@ -576,6 +578,8 @@ | |
operations/COM_MapValueOperation.h | |
operations/COM_MapRangeOperation.cpp | |
operations/COM_MapRangeOperation.h | |
+ operations/COM_ColorSpaceTransformOperation.cpp | |
+ operations/COM_ColorSpaceTransformOperation.h | |
# Distort operation | |
operations/COM_TranslateOperation.h | |
Index: source/blender/compositor/intern/COM_Converter.cpp | |
=================================================================== | |
--- source/blender/compositor/intern/COM_Converter.cpp (revision 55048) | |
+++ source/blender/compositor/intern/COM_Converter.cpp (working copy) | |
@@ -39,6 +39,7 @@ | |
#include "COM_ColorMatteNode.h" | |
#include "COM_ColorNode.h" | |
#include "COM_ColorRampNode.h" | |
+#include "COM_ColorSpaceTransformNode.h" | |
#include "COM_ColorSpillNode.h" | |
#include "COM_ColorToBWNode.h" | |
#include "COM_CombineHSVANode.h" | |
@@ -398,6 +399,9 @@ | |
case CMP_NODE_PIXELATE: | |
node = new PixelateNode(b_node); | |
break; | |
+ case CMP_NODE_COLORSPACETRANSFORM: | |
+ node = new ColorSpaceTransformNode(b_node); | |
+ break; | |
default: | |
node = new MuteNode(b_node); | |
break; | |
Index: source/blender/compositor/nodes/COM_ColorSpaceTransformNode.cpp | |
new file mode 100644 | |
=================================================================== | |
--- /dev/null (revision 55048) | |
+++ source/blender/compositor/nodes/COM_ColorSpaceTransformNode.cpp (working copy) | |
@@ -0,0 +1,48 @@ | |
+/* | |
+ * Copyright 2011, Blender Foundation. | |
+ * | |
+ * 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. | |
+ * | |
+ * Contributor: | |
+ * Jeroen Bakker | |
+ * Monique Dewanchand | |
+ */ | |
+ | |
+#include "COM_ColorSpaceTransformNode.h" | |
+ | |
+#include "COM_ColorSpaceTransformOperation.h" | |
+#include "COM_ExecutionSystem.h" | |
+ | |
+ColorSpaceTransformNode::ColorSpaceTransformNode(bNode *editorNode) : Node(editorNode) | |
+{ | |
+} | |
+ | |
+void ColorSpaceTransformNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) | |
+{ | |
+ bNode *bnode = this->getbNode(); | |
+ NodeColorSpaceTransform *bdata = (NodeColorSpaceTransform *)bnode->storage; | |
+ | |
+ InputSocket *inSocket = this->getInputSocket(0); | |
+ OutputSocket *outSocket = this->getOutputSocket(0); | |
+ | |
+ ColorSpaceTransformOperation *op = new ColorSpaceTransformOperation(); | |
+ op->setInputSpace(bdata->input_space); | |
+ op->setOutputSpace(bdata->output_space); | |
+ op->setPremulAlpha(bdata->flag & CMP_NODE_COLORSPACETRANSFORM_IS_PREMUL_ALPHA); | |
+ | |
+ inSocket->relinkConnections(op->getInputSocket(0), 0, graph); | |
+ outSocket->relinkConnections(op->getOutputSocket(0)); | |
+ graph->addOperation(op); | |
+} | |
Index: source/blender/compositor/nodes/COM_ColorSpaceTransformNode.h | |
new file mode 100644 | |
=================================================================== | |
--- source/blender/compositor/nodes/COM_ColorSpaceTransformNode.h (revision 0) | |
+++ source/blender/compositor/nodes/COM_ColorSpaceTransformNode.h (revision 0) | |
@@ -0,0 +1,37 @@ | |
+/* | |
+ * Copyright 2011, Blender Foundation. | |
+ * | |
+ * 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. | |
+ * | |
+ * Contributor: | |
+ * Jeroen Bakker | |
+ * Monique Dewanchand | |
+ */ | |
+ | |
+#ifndef _COM_ColorSpaceTransformNode_h_ | |
+#define _COM_ColorSpaceTransformNode_h_ | |
+ | |
+#include "COM_Node.h" | |
+#include "DNA_node_types.h" | |
+/** | |
+ * @brief ColorSpaceTransformNode | |
+ * @ingroup Node | |
+ */ | |
+class ColorSpaceTransformNode : public Node { | |
+public: | |
+ ColorSpaceTransformNode(bNode *editorNode); | |
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context); | |
+}; | |
+#endif | |
Index: source/blender/compositor/operations/COM_ColorSpaceTransformOperation.cpp | |
=================================================================== | |
--- /dev/null (revision 55048) | |
+++ source/blender/compositor/operations/COM_ColorSpaceTransformOperation.cpp (working copy) | |
@@ -0,0 +1,61 @@ | |
+/* | |
+ * Copyright 2011, Blender Foundation. | |
+ * | |
+ * 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. | |
+ * | |
+ * Contributor: | |
+ * Jeroen Bakker | |
+ * Monique Dewanchand | |
+ */ | |
+ | |
+#include "COM_ColorSpaceTransformOperation.h" | |
+ | |
+extern "C" { | |
+#include "IMB_colormanagement.h" | |
+} | |
+ | |
+ColorSpaceTransformOperation::ColorSpaceTransformOperation() : NodeOperation() | |
+{ | |
+ addInputSocket(COM_DT_COLOR); | |
+ addOutputSocket(COM_DT_COLOR); | |
+ m_inputOperation = NULL; | |
+ m_processor = NULL; | |
+} | |
+ | |
+void ColorSpaceTransformOperation::initExecution() | |
+{ | |
+ m_inputOperation = this->getInputSocketReader(0); | |
+ m_processor = IMB_colormanagement_colorspace_processor_new(this->m_inputSpace.c_str(), this->m_outputSpace.c_str()); | |
+} | |
+ | |
+void ColorSpaceTransformOperation::deinitExecution() | |
+{ | |
+ m_inputOperation = NULL; | |
+ if (m_processor) | |
+ IMB_colormanagement_processor_free(m_processor); | |
+ m_processor = NULL; | |
+} | |
+ | |
+void ColorSpaceTransformOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) | |
+{ | |
+ float color[4]; | |
+ m_inputOperation->read(color, x, y, sampler); | |
+ | |
+ if (m_isPremulAlpha) | |
+ IMB_colormanagement_processor_apply_v4_predivide(m_processor, color); | |
+ else | |
+ IMB_colormanagement_processor_apply_v4(m_processor, color); | |
+ copy_v4_v4(output, color); | |
+} | |
Index: source/blender/compositor/operations/COM_ColorSpaceTransformOperation.h | |
new file mode 100644 | |
=================================================================== | |
--- source/blender/compositor/operations/COM_ColorSpaceTransformOperation.h (revision 0) | |
+++ source/blender/compositor/operations/COM_ColorSpaceTransformOperation.h (revision 0) | |
@@ -0,0 +1,58 @@ | |
+/* | |
+ * Copyright 2011, Blender Foundation. | |
+ * | |
+ * 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. | |
+ * | |
+ * Contributor: | |
+ * Jeroen Bakker | |
+ * Monique Dewanchand | |
+ */ | |
+ | |
+#ifndef _COM_ColorSpaceTransformOperation_h | |
+#define _COM_ColorSpaceTransformOperation_h | |
+ | |
+#include "COM_NodeOperation.h" | |
+ | |
+struct ColormanageProcessor; | |
+ | |
+/** | |
+ * this program converts an input color to an output value. | |
+ * it assumes we are in sRGB color space. | |
+ */ | |
+class ColorSpaceTransformOperation : public NodeOperation { | |
+private: | |
+ /** | |
+ * Cached reference to the inputProgram | |
+ */ | |
+ SocketReader *m_inputOperation; | |
+ | |
+ bool m_isPremulAlpha; | |
+ std::string m_inputSpace; | |
+ std::string m_outputSpace; | |
+ ColormanageProcessor *m_processor; | |
+ | |
+public: | |
+ ColorSpaceTransformOperation(); | |
+ | |
+ void setPremulAlpha(bool is_premul_alpha) { m_isPremulAlpha = is_premul_alpha; } | |
+ void setInputSpace(const std::string &input_space) { m_inputSpace = input_space; } | |
+ void setOutputSpace(const std::string &output_space) { m_outputSpace = output_space; } | |
+ | |
+ void initExecution(); | |
+ void deinitExecution(); | |
+ | |
+ void executePixel(float output[4], float x, float y, PixelSampler sampler); | |
+}; | |
+#endif | |
Index: source/blender/editors/space_node/drawnode.c | |
=================================================================== | |
--- source/blender/editors/space_node/drawnode.c (revision 55048) | |
+++ source/blender/editors/space_node/drawnode.c (working copy) | |
@@ -2777,6 +2777,13 @@ | |
} | |
} | |
+static void node_composit_buts_colorspacetransform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) | |
+{ | |
+ uiItemR(layout, ptr, "input_space", 0, NULL, ICON_NONE); | |
+ uiItemR(layout, ptr, "output_space", 0, NULL, ICON_NONE); | |
+ uiItemR(layout, ptr, "is_premul_alpha", 0, NULL, ICON_NONE); | |
+} | |
+ | |
/* only once called */ | |
static void node_composit_set_butfunc(bNodeType *ntype) | |
{ | |
@@ -2998,6 +3005,9 @@ | |
case CMP_NODE_TRACKPOS: | |
ntype->uifunc = node_composit_buts_trackpos; | |
break; | |
+ case CMP_NODE_COLORSPACETRANSFORM: | |
+ ntype->uifunc = node_composit_buts_colorspacetransform; | |
+ break; | |
default: | |
ntype->uifunc = NULL; | |
} | |
Index: source/blender/makesdna/DNA_node_types.h | |
=================================================================== | |
--- source/blender/makesdna/DNA_node_types.h (revision 55048) | |
+++ source/blender/makesdna/DNA_node_types.h (working copy) | |
@@ -743,6 +743,13 @@ | |
char uv_map[64]; | |
} NodeShaderNormalMap; | |
+typedef struct NodeColorSpaceTransform { | |
+ char input_space[64]; /* MAX_COLORSPACE_NAME */ | |
+ char output_space[64]; /* MAX_COLORSPACE_NAME */ | |
+ | |
+ int flag; | |
+} NodeColorSpaceTransform; | |
+ | |
/* script node mode */ | |
#define NODE_SCRIPT_INTERNAL 0 | |
#define NODE_SCRIPT_EXTERNAL 1 | |
@@ -857,4 +864,8 @@ | |
/* image */ | |
#define CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT 1 | |
+typedef enum eNodeColorSpaceTransformFlag { | |
+ CMP_NODE_COLORSPACETRANSFORM_IS_PREMUL_ALPHA = 1 /* input image has associated (premultiplied) alpha */ | |
+} eNodeColorSpaceTransformFlag; | |
+ | |
#endif | |
Index: source/blender/makesrna/intern/rna_nodetree.c | |
=================================================================== | |
--- source/blender/makesrna/intern/rna_nodetree.c (revision 55048) | |
+++ source/blender/makesrna/intern/rna_nodetree.c (working copy) | |
@@ -54,6 +54,7 @@ | |
#include "BKE_texture.h" | |
#include "BKE_idprop.h" | |
+#include "IMB_colormanagement.h" | |
#include "IMB_imbuf.h" | |
#include "WM_types.h" | |
@@ -1222,6 +1223,46 @@ | |
node_update(bmain, scene, ntree, node); | |
} | |
+static int rna_NodeColorSpaceTransform_input_space_get(PointerRNA *ptr) | |
+{ | |
+ bNode *node = ptr->data; | |
+ NodeColorSpaceTransform *data = node->storage; | |
+ return IMB_colormanagement_colorspace_get_named_index(data->input_space); | |
+} | |
+ | |
+static void rna_NodeColorSpaceTransform_input_space_set(PointerRNA *ptr, int value) | |
+{ | |
+ bNode *node = ptr->data; | |
+ NodeColorSpaceTransform *data = node->storage; | |
+ BLI_strncpy(data->input_space, IMB_colormanagement_colorspace_get_indexed_name(value), sizeof(data->input_space)); | |
+} | |
+ | |
+static int rna_NodeColorSpaceTransform_output_space_get(PointerRNA *ptr) | |
+{ | |
+ bNode *node = ptr->data; | |
+ NodeColorSpaceTransform *data = node->storage; | |
+ return IMB_colormanagement_colorspace_get_named_index(data->output_space); | |
+} | |
+ | |
+static void rna_NodeColorSpaceTransform_output_space_set(PointerRNA *ptr, int value) | |
+{ | |
+ bNode *node = ptr->data; | |
+ NodeColorSpaceTransform *data = node->storage; | |
+ BLI_strncpy(data->output_space, IMB_colormanagement_colorspace_get_indexed_name(value), sizeof(data->output_space)); | |
+} | |
+ | |
+static EnumPropertyItem *rna_NodeColorSpaceTransform_space_items(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), | |
+ PropertyRNA *UNUSED(prop), int *free) | |
+{ | |
+ EnumPropertyItem *item = NULL; | |
+ int totitem = 0; | |
+ | |
+ IMB_colormanagement_colorspace_items_add(&item, &totitem); | |
+ *free = 1; | |
+ | |
+ return item; | |
+} | |
+ | |
#else | |
static EnumPropertyItem prop_image_layer_items[] = { | |
@@ -4272,6 +4313,35 @@ | |
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | |
} | |
+static void def_cmp_colorspacetransform(StructRNA *srna) | |
+{ | |
+ PropertyRNA *prop; | |
+ | |
+ static EnumPropertyItem dummy_items[] = { | |
+ {-1, "DUMMY", 0, "", ""}, | |
+ {0, NULL, 0, NULL, NULL} | |
+ }; | |
+ | |
+ RNA_def_struct_sdna_from(srna, "NodeColorSpaceTransform", "storage"); | |
+ | |
+ prop = RNA_def_property(srna, "input_space", PROP_ENUM, PROP_NONE); | |
+ RNA_def_property_enum_funcs(prop, "rna_NodeColorSpaceTransform_input_space_get", "rna_NodeColorSpaceTransform_input_space_set", "rna_NodeColorSpaceTransform_space_items"); | |
+ RNA_def_property_enum_items(prop, dummy_items); | |
+ RNA_def_property_ui_text(prop, "Input Space", "Color space of the input image"); | |
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | |
+ | |
+ prop = RNA_def_property(srna, "output_space", PROP_ENUM, PROP_NONE); | |
+ RNA_def_property_enum_funcs(prop, "rna_NodeColorSpaceTransform_output_space_get", "rna_NodeColorSpaceTransform_output_space_set", "rna_NodeColorSpaceTransform_space_items"); | |
+ RNA_def_property_enum_items(prop, dummy_items); | |
+ RNA_def_property_ui_text(prop, "Output Space", "Target color space of the output image"); | |
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | |
+ | |
+ prop = RNA_def_property(srna, "is_premul_alpha", PROP_BOOLEAN, PROP_NONE); | |
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", CMP_NODE_COLORSPACETRANSFORM_IS_PREMUL_ALPHA); | |
+ RNA_def_property_ui_text(prop, "Premul Alpha", "Input image has associated (premultiplied) alpha, predivide to get correct colors"); | |
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); | |
+} | |
+ | |
/* -- Texture Nodes --------------------------------------------------------- */ | |
Index: source/blender/makesrna/intern/rna_nodetree_types.h | |
=================================================================== | |
--- source/blender/makesrna/intern/rna_nodetree_types.h (revision 55048) | |
+++ source/blender/makesrna/intern/rna_nodetree_types.h (working copy) | |
@@ -186,6 +186,7 @@ | |
DefNode( CompositorNode, CMP_NODE_KEYING, def_cmp_keying, "KEYING", Keying, "Keying", "" ) | |
DefNode( CompositorNode, CMP_NODE_TRACKPOS, def_cmp_trackpos, "TRACKPOS", TrackPos, "Track Position", "" ) | |
DefNode( CompositorNode, CMP_NODE_PIXELATE, 0, "PIXELATE", Pixelate, "Pixelate", "" ) | |
+DefNode( CompositorNode, CMP_NODE_COLORSPACETRANSFORM, def_cmp_colorspacetransform, "COLORSPACETRANSFORM", ColorSpaceTransform, "Color Space Transform", "") | |
DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) | |
DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) | |
Index: source/blender/nodes/CMakeLists.txt | |
=================================================================== | |
--- source/blender/nodes/CMakeLists.txt (revision 55048) | |
+++ source/blender/nodes/CMakeLists.txt (working copy) | |
@@ -121,6 +121,7 @@ | |
composite/nodes/node_composite_switch.c | |
composite/nodes/node_composite_colorcorrection.c | |
composite/nodes/node_composite_pixelate.c | |
+ composite/nodes/node_composite_colorspacetransform.c | |
composite/node_composite_tree.c | |
composite/node_composite_util.h | |
Index: source/blender/nodes/NOD_composite.h | |
=================================================================== | |
--- source/blender/nodes/NOD_composite.h (revision 55048) | |
+++ source/blender/nodes/NOD_composite.h (working copy) | |
@@ -127,6 +127,7 @@ | |
void register_node_type_cmp_colorcorrection(struct bNodeTreeType *ttype); | |
+void register_node_type_cmp_colorspacetransform(struct bNodeTreeType *ttype); | |
void register_node_type_cmp_boxmask(struct bNodeTreeType *ttype); | |
void register_node_type_cmp_ellipsemask(struct bNodeTreeType *ttype); | |
void register_node_type_cmp_bokehimage(struct bNodeTreeType *ttype); | |
Index: source/blender/nodes/composite/nodes/node_composite_colorspacetransform.c | |
new file mode 100644 | |
=================================================================== | |
--- source/blender/nodes/composite/nodes/node_composite_colorspacetransform.c (revision 0) | |
+++ source/blender/nodes/composite/nodes/node_composite_colorspacetransform.c (revision 0) | |
@@ -0,0 +1,67 @@ | |
+/* | |
+ * ***** BEGIN GPL LICENSE BLOCK ***** | |
+ * | |
+ * 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. | |
+ * | |
+ * The Original Code is: all of this file. | |
+ * | |
+ * Contributor(s): Matt Ebb. | |
+ * | |
+ * ***** END GPL LICENSE BLOCK ***** | |
+ */ | |
+ | |
+/** \file blender/nodes/composite/nodes/node_composite_colorspacetransform.c | |
+ * \ingroup cmpnodes | |
+ */ | |
+ | |
+ | |
+ | |
+#include "node_composite_util.h" | |
+ | |
+#include "IMB_colormanagement.h" | |
+ | |
+ | |
+static bNodeSocketTemplate inputs[] = { | |
+ {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, | |
+ {-1, 0, ""} | |
+}; | |
+ | |
+static bNodeSocketTemplate outputs[] = { | |
+ {SOCK_RGBA, 0, N_("Image")}, | |
+ {-1, 0, ""} | |
+}; | |
+ | |
+static void node_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) | |
+{ | |
+ NodeColorSpaceTransform *data = node->storage = MEM_callocN(sizeof(NodeColorSpaceTransform), "color space transform node"); | |
+ | |
+ BLI_strncpy(data->input_space, IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR), sizeof(data->input_space)); | |
+ BLI_strncpy(data->output_space, IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR), sizeof(data->output_space)); | |
+} | |
+ | |
+void register_node_type_cmp_colorspacetransform(bNodeTreeType *ttype) | |
+{ | |
+ static bNodeType ntype; | |
+ | |
+ node_type_base(ttype, &ntype, CMP_NODE_COLORSPACETRANSFORM, "Color Space Transform", NODE_CLASS_OP_COLOR, NODE_OPTIONS); | |
+ node_type_socket_templates(&ntype, inputs, outputs); | |
+ node_type_init(&ntype, node_init); | |
+ node_type_storage(&ntype, "NodeColorSpaceTransform", node_free_standard_storage, node_copy_standard_storage); | |
+ | |
+ nodeRegisterType(ttype, &ntype); | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment