Added gamma, fixed typos in brightness
authorRobert Holcomb <bob_holcomb@hotmail.com>
Fri, 13 Apr 2007 04:22:32 +0000 (04:22 +0000)
committerRobert Holcomb <bob_holcomb@hotmail.com>
Fri, 13 Apr 2007 04:22:32 +0000 (04:22 +0000)
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/intern/node.c
source/blender/nodes/CMP_node.h
source/blender/nodes/intern/CMP_nodes/CMP_brightness.c
source/blender/nodes/intern/CMP_nodes/CMP_gamma.c [new file with mode: 0644]

index 95d26aa0abdad3d15e943fcddf9f8aaee61d1f94..bace38651eae00cb443173e6c96768db983c1962 100644 (file)
@@ -295,6 +295,7 @@ void                        set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
 #define CMP_NODE_LUMA_MATTE    248
 
 #define CMP_NODE_BRIGHTCONTRAST 249
+#define CMP_NODE_GAMMA         250
 
 /* filter types */
 #define CMP_FILT_SOFT          0
index 93b629e0ef3a029c346da3bc5208866a7595ace6..842e07cebe7dec43c936f9f51763a0dc36cfd4b3 100644 (file)
@@ -2363,6 +2363,7 @@ static void registerCompositNodes(ListBase *ntypelist)
        nodeRegisterType(ntypelist, &cmp_node_mapuv);
 
        nodeRegisterType(ntypelist, &cmp_node_brightcontrast);
+       nodeRegisterType(ntypelist, &cmp_node_gamma);
 }
 
 static void registerShaderNodes(ListBase *ntypelist) 
index 77e70a3c12624f99a121904cd0104565250c75ed..ea15d4dbe73687bb8ada6d445bdf4186098cb6d4 100644 (file)
@@ -94,6 +94,7 @@ extern bNodeType cmp_node_displace;
 extern bNodeType cmp_node_mapuv;
 
 extern bNodeType cmp_node_brightcontrast;
+extern bNodeType cmp_node_gamma;
 
 #endif
 
index bb411a47d34b26d9803419757c841568dc8cd91c..c87307434b5f939cbda236f0eef9d181b49d9592 100644 (file)
 
 /* **************** Brigh and contrsast  ******************** */
 
-static bNodeSocketType cmp_node_brightcontrsast_in[]= {
+static bNodeSocketType cmp_node_brightcontrast_in[]= {
        {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
        {       SOCK_VALUE, 1, "bright",                0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f},
        {       SOCK_VALUE, 1, "contrast",              0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f},
        {       -1, 0, ""       }
 };
-static bNodeSocketType cmp_node_brightcontrsast_out[]= {
+static bNodeSocketType cmp_node_brightcontrast_out[]= {
        {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
        {       -1, 0, ""       }
 };
@@ -77,7 +77,7 @@ static void do_brightnesscontrast(bNode *node, float *out, float *in)
        }
 }
 
-static void node_composit_exec_brightcontrsast(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+static void node_composit_exec_brightcontrast(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
        if(out[0]->hasoutput==0)
                return;
@@ -94,16 +94,16 @@ static void node_composit_exec_brightcontrsast(void *data, bNode *node, bNodeSta
        }
 }
 
-bNodeType cmp_node_brighcontrast= {
+bNodeType cmp_node_brightcontrast= {
        /* *next,*prev */       NULL, NULL,
        /* type code   */       CMP_NODE_BRIGHTCONTRAST,
        /* name        */       "Bright/Contrast",
        /* width+range */       140, 100, 320,
        /* class+opts  */       NODE_CLASS_OP_COLOR, NODE_OPTIONS,
-       /* input sock  */       cmp_node_brightcontrsast_in,
-       /* output sock */       cmp_node_brightcontrsast_out,
+       /* input sock  */       cmp_node_brightcontrast_in,
+       /* output sock */       cmp_node_brightcontrast_out,
        /* storage     */       "",
-       /* execfunc    */       node_composit_exec_brightcontrsast,
+       /* execfunc    */       node_composit_exec_brightcontrast,
        /* butfunc     */       NULL, 
        /* initfunc    */       NULL, 
        /* freestoragefunc      */ NULL, 
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c b/source/blender/nodes/intern/CMP_nodes/CMP_gamma.c
new file mode 100644 (file)
index 0000000..5d0ab72
--- /dev/null
@@ -0,0 +1,91 @@
+/**
+* $Id$
+*
+* ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+* 
+* The Original Code is Copyright (C) 2006 Blender Foundation.
+* All rights reserved.
+* 
+* The Original Code is: all of this file.
+* 
+* Contributor(s): none yet.
+* 
+* ***** END GPL LICENSE BLOCK *****
+
+*/
+
+#include "../CMP_util.h"
+
+/* **************** Gamma Tools  ******************** */
+  
+static bNodeSocketType cmp_node_gamma_in[]= {
+       {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+       {       SOCK_VALUE, 1, "Gamma",                 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 2.0f},
+    {  -1, 0, ""       }
+};
+static bNodeSocketType cmp_node_gamma_out[]= {
+       {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+       {       -1, 0, ""       }
+};
+
+static void do_gamma(bNode *node, float *out, float *in, float *fac)
+{
+       int i=0;
+       for(i=0; i<3; i++) {
+               out[i] = pow(in[i],fac[0]);
+       }
+       out[3] = in[3];
+}
+static void node_composit_exec_gamma(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+       /* stack order in: Fac, Image */
+       /* stack order out: Image */
+       if(out[0]->hasoutput==0) return;
+       
+       /* input no image? then only color operation */
+       if(in[0]->data==NULL) {
+               do_gamma(node, out[0]->vec, in[0]->vec, in[1]->vec);
+       }
+       else {
+               /* make output size of input image */
+               CompBuf *cbuf= in[0]->data;
+               CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); // allocs
+               
+               composit2_pixel_processor(node, stackbuf, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_gamma, CB_RGBA, CB_VAL);
+
+               out[0]->data= stackbuf;
+       }
+}
+
+bNodeType cmp_node_gamma= {
+       /* *next,*prev */       NULL, NULL,
+       /* type code   */       CMP_NODE_GAMMA,
+       /* name        */       "Gamma",
+       /* width+range */       140, 100, 320,
+       /* class+opts  */       NODE_CLASS_OP_COLOR, NODE_OPTIONS,
+       /* input sock  */       cmp_node_gamma_in,
+       /* output sock */       cmp_node_gamma_out,
+       /* storage     */       "",
+       /* execfunc    */       node_composit_exec_gamma,       
+        /* butfunc     */       NULL,
+        /* initfunc    */       NULL,
+        /* freestoragefunc      */ NULL,
+        /* copysotragefunc      */ NULL,
+        /* id          */       NULL
+};
+
+