[Bf-blender-cvs] [5c50820] texture_nodes_refactor: Bring back image input, checker, viewer and output nodes

Sergey Sharybin noreply at git.blender.org
Sat Oct 11 17:02:40 CEST 2014


Commit: 5c50820e6aa45c8731ed48e01c65d5e762ab9094
Author: Sergey Sharybin
Date:   Sat Oct 11 20:58:59 2014 +0600
Branches: texture_nodes_refactor
https://developer.blender.org/rB5c50820e6aa45c8731ed48e01c65d5e762ab9094

Bring back image input, checker, viewer and output nodes

This more like a prove-of-concept change because well, we've got
a dependency solver in the nodes already which seems to work just
fine for the shading nodes. So want to see if this is something we
can use for texture nodes now.

This isn't that far away from the original idea of having some
SVM-like machine for texture nodes.

Hell of a lot of nodes are not gonna to work yet,

===================================================================

M	source/blender/nodes/texture/node_texture_tree.c
M	source/blender/nodes/texture/node_texture_util.c
M	source/blender/nodes/texture/node_texture_util.h
M	source/blender/nodes/texture/nodes/node_texture_at.c
M	source/blender/nodes/texture/nodes/node_texture_bricks.c
M	source/blender/nodes/texture/nodes/node_texture_checker.c
M	source/blender/nodes/texture/nodes/node_texture_compose.c
M	source/blender/nodes/texture/nodes/node_texture_curves.c
M	source/blender/nodes/texture/nodes/node_texture_decompose.c
M	source/blender/nodes/texture/nodes/node_texture_distance.c
M	source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
M	source/blender/nodes/texture/nodes/node_texture_image.c
M	source/blender/nodes/texture/nodes/node_texture_invert.c
M	source/blender/nodes/texture/nodes/node_texture_math.c
M	source/blender/nodes/texture/nodes/node_texture_mixRgb.c
M	source/blender/nodes/texture/nodes/node_texture_output.c
M	source/blender/nodes/texture/nodes/node_texture_proc.c
M	source/blender/nodes/texture/nodes/node_texture_rotate.c
M	source/blender/nodes/texture/nodes/node_texture_scale.c
M	source/blender/nodes/texture/nodes/node_texture_texture.c
M	source/blender/nodes/texture/nodes/node_texture_translate.c
M	source/blender/nodes/texture/nodes/node_texture_valToNor.c
M	source/blender/nodes/texture/nodes/node_texture_valToRgb.c
M	source/blender/nodes/texture/nodes/node_texture_viewer.c

===================================================================

diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index e238d11..bf97037 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -293,8 +293,6 @@ int ntreeTexExecTree(
 	                                   &ntree->id);
 	BLI_assert(exec != NULL);
 
-	return 0;
-
 	data.co = co;
 	data.dxt = dxt;
 	data.dyt = dyt;
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index 76e14c2..784c015 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -63,22 +63,52 @@ void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, sho
 	ntype->update_internal_links = node_update_internal_links_default;
 }
 
-static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread)
+/* TODO(sergey): De-duplicate with the shader nodes. */
+static void tex_input(float *in, int type_in, bNodeStack *ns)
 {
-	(void) in;
-	(void) params;
-	(void) thread;
-	memset(out, 0, sz * sizeof(float));
+	const float *from = ns->vec;
+
+	if (type_in == SOCK_FLOAT) {
+		if (ns->sockettype == SOCK_FLOAT)
+			*in = *from;
+		else
+			*in = (from[0] + from[1] + from[2]) / 3.0f;
+	}
+	else if (type_in == SOCK_VECTOR) {
+		if (ns->sockettype == SOCK_FLOAT) {
+			in[0] = from[0];
+			in[1] = from[0];
+			in[2] = from[0];
+		}
+		else {
+			copy_v3_v3(in, from);
+		}
+	}
+	else { /* type_in==SOCK_RGBA */
+		if (ns->sockettype == SOCK_RGBA) {
+			copy_v4_v4(in, from);
+		}
+		else if (ns->sockettype == SOCK_FLOAT) {
+			in[0] = from[0];
+			in[1] = from[0];
+			in[2] = from[0];
+			in[3] = 1.0f;
+		}
+		else {
+			copy_v3_v3(in, from);
+			in[3] = 1.0f;
+		}
+	}
 }
 
-void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
+void tex_input_vec(float *out, bNodeStack *in)
 {
-	tex_input(out, 3, in, params, thread);
+	tex_input(out, SOCK_FLOAT, in);
 }
 
-void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
+void tex_input_rgba(float *out, bNodeStack *in)
 {
-	tex_input(out, 4, in, params, thread);
+	tex_input(out, SOCK_RGBA, in);
 	
 	if (in->hasoutput && in->sockettype == SOCK_FLOAT) {
 		out[1] = out[2] = out[0];
@@ -93,10 +123,10 @@ void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
 	}
 }
 
-float tex_input_value(bNodeStack *in, TexParams *params, short thread)
+float tex_input_value(bNodeStack *in)
 {
 	float out[4];
-	tex_input_vec(out, in, params, thread);
+	tex_input_vec(out, in);
 	return out[0];
 }
 
diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h
index 36885d3..aa869d7 100644
--- a/source/blender/nodes/texture/node_texture_util.h
+++ b/source/blender/nodes/texture/node_texture_util.h
@@ -112,9 +112,9 @@ typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **i
 int tex_node_poll_default(struct bNodeType *ntype, struct bNodeTree *ntree);
 void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag);
 
-void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread);
-void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread);
-float tex_input_value(bNodeStack *in, TexParams *params, short thread);
+void tex_input_rgba(float *out, bNodeStack *in);
+void tex_input_vec(float *out, bNodeStack *in);
+float tex_input_value(bNodeStack *in);
 
 void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *data);
 void tex_do_preview(bNodePreview *preview, const float coord[2], const float col[4], bool do_manage);
diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c
index aafb979..c316543 100644
--- a/source/blender/nodes/texture/nodes/node_texture_at.c
+++ b/source/blender/nodes/texture/nodes/node_texture_at.c
@@ -49,8 +49,12 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **
 	float new_co[3];
 	np.co = new_co;
 	
-	tex_input_vec(new_co, in[1], p, thread);
-	tex_input_rgba(out, in[0], &np, thread);
+	(void) out;
+	(void) in;
+	(void) thread;
+	tex_input_vec(new_co, in[1]);
+	//tex_input_rgba(out, in[0], &np, thread);
+	BLI_assert(!"Needs proper solution");
 }
 
 static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c
index 02d4ddd..25cb7c6 100644
--- a/source/blender/nodes/texture/nodes/node_texture_bricks.c
+++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c
@@ -64,7 +64,7 @@ static float noise(int n) /* fast integer noise */
 	return 0.5f * ((float)nn / 1073741824.0f);
 }
 
-static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
+static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short UNUSED(thread))
 {
 	const float *co = p->co;
 	
@@ -80,14 +80,14 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
 	float bricks2[4];
 	float mortar[4];
 	
-	float mortar_thickness = tex_input_value(in[3], p, thread);
-	float bias             = tex_input_value(in[4], p, thread);
-	float brick_width      = tex_input_value(in[5], p, thread);
-	float row_height       = tex_input_value(in[6], p, thread);
+	float mortar_thickness = tex_input_value(in[3]);
+	float bias             = tex_input_value(in[4]);
+	float brick_width      = tex_input_value(in[5]);
+	float row_height       = tex_input_value(in[6]);
 	
-	tex_input_rgba(bricks1, in[0], p, thread);
-	tex_input_rgba(bricks2, in[1], p, thread);
-	tex_input_rgba(mortar,  in[2], p, thread);
+	tex_input_rgba(bricks1, in[0]);
+	tex_input_rgba(bricks2, in[1]);
+	tex_input_rgba(mortar,  in[2]);
 	
 	rownum = (int)floor(y / row_height);
 	
diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c
index c26a96c..e57bd63 100644
--- a/source/blender/nodes/texture/nodes/node_texture_checker.c
+++ b/source/blender/nodes/texture/nodes/node_texture_checker.c
@@ -45,29 +45,38 @@ static bNodeSocketTemplate outputs[] = {
 	{ -1, 0, "" }
 };
 
-static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
+static void exec(void *data,
+                 int UNUSED(thread),
+                 bNode *UNUSED(node),
+                 bNodeExecData *execdata,
+                 bNodeStack **in,
+                 bNodeStack **out)
 {
-	float x  = p->co[0];
-	float y  = p->co[1];
-	float z  = p->co[2];
-	float sz = tex_input_value(in[2], p, thread);
-	
+	TexCallData *cdata = (TexCallData *)data;
+	TexParams p;
+	float x, y, z, sz;
+	int xi, yi, zi;
+
+	params_from_cdata(&p, cdata);
+
+	x  = p.co[0];
+	y  = p.co[1];
+	z  = p.co[2];
+	sz = tex_input_value(in[2]);
+
 	/* 0.00001  because of unit sized stuff */
-	int xi = (int)fabs(floor(0.00001f + x / sz));
-	int yi = (int)fabs(floor(0.00001f + y / sz));
-	int zi = (int)fabs(floor(0.00001f + z / sz));
-	
+	xi = (int)fabsf(floorf(0.00001f + x / sz));
+	yi = (int)fabsf(floorf(0.00001f + y / sz));
+	zi = (int)fabsf(floorf(0.00001f + z / sz));
+
 	if ( (xi % 2 == yi % 2) == (zi % 2) ) {
-		tex_input_rgba(out, in[0], p, thread);
+		tex_input_rgba(out[0]->vec, in[0]);
 	}
 	else {
-		tex_input_rgba(out, in[1], p, thread);
+		tex_input_rgba(out[0]->vec, in[1]);
 	}
-}
 
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
-{
-	tex_output(node, execdata, in, out[0], &colorfn, data);
+	tex_do_preview(execdata->preview, p.co, out[0]->vec, cdata->do_manage);
 }
 
 void register_node_type_tex_checker(void)
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index 0881366..495377b 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.c
@@ -45,11 +45,11 @@ static bNodeSocketTemplate outputs[] = {
 	{ -1, 0, "" }
 };
 
-static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
+static void colorfn(float *out, TexParams *UNUSED(p), bNode *UNUSED(node), bNodeStack **in, short UNUSED(thread))
 {
 	int i;
 	for (i = 0; i < 4; i++)
-		out[i] = tex_input_value(in[i], p, thread);
+		out[i] = tex_input_value(in[i]);
 }
 
 static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index 897157e..06ec5c0 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -92,10 +92,10 @@ static bNodeSocketTemplate rgb_outputs[] = {
 	{	-1, 0, ""}
 };
 
-static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
+static void rgb_colorfn(float *out, TexParams *UNUSED(p), bNode *node, bNodeStack **in, short UNUSED(thread))
 {
 	float cin[4];
-	tex_input_rgba(cin, in[0], p, thread);
+	tex_input_rgba(cin, in[0]);
 	
 	curvemapping_evaluateRGBF(node->storage, out, cin);
 	out[3] = cin[3];
diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c
index 4bdc66b..ee3ec4a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_decompose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c
@@ -46,27 +46,27 @@ static bNodeSocketTemplate outputs[] = {
 	{ -1, 0, "" }
 };
 
-static void valuefn_r(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
+static void valuefn_r(float *out, TexParams *UNUSED(p), bNode *UNUSED(node), bNodeStack **in, short UNUSED(thread))
 {
-	tex_input_rgba(out, in[0], p, thread);
+	tex_input_rgba(

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list