[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18822] trunk/blender/source/blender: Added compose/decompose, fixed bugs.

Robin Allen roblovski at gmail.com
Fri Feb 6 01:55:44 CET 2009


Revision: 18822
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18822
Author:   kakbarnf
Date:     2009-02-06 01:55:38 +0100 (Fri, 06 Feb 2009)

Log Message:
-----------
Added compose/decompose, fixed bugs.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/nodes/TEX_node.h
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_proc.c

Added Paths:
-----------
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_compose.c
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2009-02-05 19:28:28 UTC (rev 18821)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2009-02-06 00:55:38 UTC (rev 18822)
@@ -403,6 +403,8 @@
 #define TEX_NODE_TRANSLATE  116
 #define TEX_NODE_COORD      117
 #define TEX_NODE_DISTANCE   118
+#define TEX_NODE_COMPOSE    119
+#define TEX_NODE_DECOMPOSE  120
 
 /* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
 #define TEX_NODE_PROC      200

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2009-02-05 19:28:28 UTC (rev 18821)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2009-02-06 00:55:38 UTC (rev 18822)
@@ -2888,6 +2888,8 @@
 	nodeRegisterType(ntypelist, &tex_node_hue_sat);
 	nodeRegisterType(ntypelist, &tex_node_coord);
 	nodeRegisterType(ntypelist, &tex_node_distance);
+	nodeRegisterType(ntypelist, &tex_node_compose);
+	nodeRegisterType(ntypelist, &tex_node_decompose);
 	
 	nodeRegisterType(ntypelist, &tex_node_output);
 	nodeRegisterType(ntypelist, &tex_node_viewer);

Modified: trunk/blender/source/blender/nodes/TEX_node.h
===================================================================
--- trunk/blender/source/blender/nodes/TEX_node.h	2009-02-05 19:28:28 UTC (rev 18821)
+++ trunk/blender/source/blender/nodes/TEX_node.h	2009-02-06 00:55:38 UTC (rev 18822)
@@ -58,6 +58,9 @@
 extern bNodeType tex_node_rotate;
 extern bNodeType tex_node_translate;
 
+extern bNodeType tex_node_compose;
+extern bNodeType tex_node_decompose;
+
 extern bNodeType tex_node_proc_voronoi;
 extern bNodeType tex_node_proc_blend;
 extern bNodeType tex_node_proc_magic;

Added: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_compose.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_compose.c	                        (rev 0)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_compose.c	2009-02-06 00:55:38 UTC (rev 18822)
@@ -0,0 +1,71 @@
+/**
+ *
+ * ***** 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) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../TEX_util.h"                                                   
+
+static bNodeSocketType inputs[]= {
+	{ SOCK_VALUE, 1, "Red",   0.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_VALUE, 1, "Blue",  0.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ -1, 0, "" }
+};
+static bNodeSocketType outputs[]= {
+	{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+	{ -1, 0, "" }
+};
+
+static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	int i;
+	for(i = 0; i < 4; i++)
+		out[i] = tex_input_value(in[i], coord, thread);
+}
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+	tex_output(node, in, out[0], &colorfn);
+}
+
+bNodeType tex_node_compose= {
+	/* *next,*prev     */  NULL, NULL,
+	/* type code       */  TEX_NODE_COMPOSE,
+	/* name            */  "Compose RGBA",
+	/* width+range     */  100, 60, 150,
+	/* class+opts      */  NODE_CLASS_OP_COLOR, 0,
+	/* input sock      */  inputs,
+	/* output sock     */  outputs,
+	/* storage         */  "", 
+	/* execfunc        */  exec,
+	/* butfunc         */  NULL,
+	/* initfunc        */  NULL,
+	/* freestoragefunc */  NULL,
+	/* copystoragefunc */  NULL,
+	/* id              */  NULL   
+	
+};

Added: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c	                        (rev 0)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_decompose.c	2009-02-06 00:55:38 UTC (rev 18822)
@@ -0,0 +1,92 @@
+/**
+ *
+ * ***** 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) 2005 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "../TEX_util.h"                                                   
+#include <math.h>
+
+static bNodeSocketType inputs[]= {
+	{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f },
+	{ -1, 0, "" }
+};
+static bNodeSocketType outputs[]= {
+	{ SOCK_VALUE, 1, "Red",   0.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_VALUE, 1, "Green", 0.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_VALUE, 1, "Blue",  0.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ -1, 0, "" }
+};
+
+static void valuefn_r(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	tex_input_rgba(out, in[0], coord, thread);
+	*out = out[0];
+}
+
+static void valuefn_g(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	tex_input_rgba(out, in[0], coord, thread);
+	*out = out[1];
+}
+
+static void valuefn_b(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	tex_input_rgba(out, in[0], coord, thread);
+	*out = out[2];
+}
+
+static void valuefn_a(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
+{
+	tex_input_rgba(out, in[0], coord, thread);
+	*out = out[3];
+}
+
+static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+	tex_output(node, in, out[0], &valuefn_r);
+	tex_output(node, in, out[1], &valuefn_g);
+	tex_output(node, in, out[2], &valuefn_b);
+	tex_output(node, in, out[3], &valuefn_a);
+}
+
+bNodeType tex_node_decompose= {
+	/* *next,*prev     */  NULL, NULL,
+	/* type code       */  TEX_NODE_DECOMPOSE,
+	/* name            */  "Decompose RGBA",
+	/* width+range     */  100, 60, 150,
+	/* class+opts      */  NODE_CLASS_OP_COLOR, 0,
+	/* input sock      */  inputs,
+	/* output sock     */  outputs,
+	/* storage         */  "", 
+	/* execfunc        */  exec,
+	/* butfunc         */  NULL,
+	/* initfunc        */  NULL,
+	/* freestoragefunc */  NULL,
+	/* copystoragefunc */  NULL,
+	/* id              */  NULL   
+	
+};

Modified: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c	2009-02-05 19:28:28 UTC (rev 18821)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_hueSatVal.c	2009-02-06 00:55:38 UTC (rev 18822)
@@ -30,16 +30,16 @@
 
 
 static bNodeSocketType inputs[]= {
-	{	SOCK_VALUE, 1, "Hue",			0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-	{	SOCK_VALUE, 1, "Saturation",		1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f},
-	{	SOCK_VALUE, 1, "Value",			1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f},
-	{	SOCK_VALUE, 1, "Fac",			1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
-	{	SOCK_RGBA, 1, "Color",			0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
-	{	-1, 0, ""	}
+	{ SOCK_VALUE, 1, "Hue",        0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f },
+	{ SOCK_VALUE, 1, "Saturation", 1.0f, 0.0f, 0.0f, 0.0f,  0.0f, 2.0f },
+	{ SOCK_VALUE, 1, "Value",      1.0f, 0.0f, 0.0f, 0.0f,  0.0f, 2.0f },
+	{ SOCK_VALUE, 1, "Factor",     1.0f, 0.0f, 0.0f, 0.0f,  0.0f, 1.0f },
+	{ SOCK_RGBA,  1, "Color",      0.8f, 0.8f, 0.8f, 1.0f,  0.0f, 1.0f },
+	{ -1, 0, "" }
 };
 static bNodeSocketType outputs[]= {
-	{	SOCK_RGBA, 0, "Color",			0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
-	{	-1, 0, ""	}
+	{ SOCK_RGBA, 0, "Color",       0.0f, 0.0f, 0.0f, 1.0f,  0.0f, 1.0f },
+	{ -1, 0, "" }
 };
 
 static void do_hue_sat_fac(bNode *node, float *out, float hue, float sat, float val, float *in, float fac)
@@ -67,15 +67,19 @@
 
 static void colorfn(float *out, float *coord, bNode *node, bNodeStack **in, short thread)
 {	
-	float in0 = tex_input_value(in[0], coord, thread);
-	float in1 = tex_input_value(in[1], coord, thread);
-	float in2 = tex_input_value(in[2], coord, thread);
-	float in3 = tex_input_value(in[3], coord, thread);
+	float hue = tex_input_value(in[0], coord, thread);
+	float sat = tex_input_value(in[1], coord, thread);
+	float val = tex_input_value(in[2], coord, thread);
+	float fac = tex_input_value(in[3], coord, thread);
 	
-	float in4[4];
-	tex_input_rgba(in4, in[4], coord, thread);
+	float col[4];
+	tex_input_rgba(col, in[4], coord, thread);
 	
-	do_hue_sat_fac(node, out, in0, in1, in2, in4, in3);
+	hue += 0.5f; /* [-.5, .5] -> [0, 1] */
+	
+	do_hue_sat_fac(node, out, hue, sat, val, col, fac);
+	
+	out[3] = col[3];
 }
 
 static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)

Modified: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_proc.c

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list