Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/nodes/texture/nodes
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/nodes/texture/nodes')
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_at.c42
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_bricks.c150
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_checker.c60
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c194
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_compose.c40
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_coord.c31
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c98
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_decompose.c56
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_distance.c40
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_hueSatVal.c107
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c130
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_invert.c42
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c381
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_mixRgb.c54
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c217
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c394
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_rotate.c94
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_scale.c54
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_texture.c109
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_translate.c46
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToNor.c72
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_valToRgb.c81
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_viewer.c44
23 files changed, 1305 insertions, 1231 deletions
diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c
index 82e545cfd8e..f645b04a161 100644
--- a/source/blender/nodes/texture/nodes/node_texture_at.c
+++ b/source/blender/nodes/texture/nodes/node_texture_at.c
@@ -21,43 +21,47 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Texture"), 0.0f, 0.0f, 0.0f, 1.0f },
- { SOCK_VECTOR, 1, N_("Coordinates"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Texture"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_VECTOR, 1, N_("Coordinates"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Texture") },
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Texture")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- TexParams np = *p;
- float new_co[3];
- np.co = new_co;
+ TexParams np = *p;
+ 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);
+ tex_input_vec(new_co, in[1], p, thread);
+ tex_input_rgba(out, in[0], &np, thread);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_at(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_size(&ntype, 140, 100, 320);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c
index 0f034de99ec..c500fa31d34 100644
--- a/source/blender/nodes/texture/nodes/node_texture_bricks.c
+++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c
@@ -21,107 +21,109 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
#include <math.h>
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f },
- { SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f },
- { SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f },
- { SOCK_FLOAT, 1, N_("Thickness"), 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Bias"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("Brick Width"), 0.5f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f},
+ {SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f},
+ {SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_FLOAT, 1, N_("Thickness"), 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Bias"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("Brick Width"), 0.5f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, ""},
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
- node->custom3 = 0.5; /* offset */
- node->custom4 = 1.0; /* squash */
+ node->custom3 = 0.5; /* offset */
+ node->custom4 = 1.0; /* squash */
}
static float noise(int n) /* fast integer noise */
{
- int nn;
- n = (n >> 13) ^ n;
- nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
- return 0.5f * ((float)nn / 1073741824.0f);
+ int nn;
+ n = (n >> 13) ^ n;
+ nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
+ return 0.5f * ((float)nn / 1073741824.0f);
}
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- const float *co = p->co;
-
- float x = co[0];
- float y = co[1];
-
- int bricknum, rownum;
- float offset = 0;
- float ins_x, ins_y;
- float tint;
-
- float bricks1[4];
- 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);
-
- tex_input_rgba(bricks1, in[0], p, thread);
- tex_input_rgba(bricks2, in[1], p, thread);
- tex_input_rgba(mortar, in[2], p, thread);
-
- rownum = (int)floor(y / row_height);
-
- if (node->custom1 && node->custom2) {
- brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */
- offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */
- }
-
- bricknum = (int)floor((x + offset) / brick_width);
-
- ins_x = (x + offset) - brick_width * bricknum;
- ins_y = y - row_height * rownum;
-
- tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias;
- CLAMP(tint, 0.0f, 1.0f);
-
- if (ins_x < mortar_thickness || ins_y < mortar_thickness ||
- ins_x > (brick_width - mortar_thickness) ||
- ins_y > (row_height - mortar_thickness))
- {
- copy_v4_v4(out, mortar);
- }
- else {
- copy_v4_v4(out, bricks1);
- ramp_blend(MA_RAMP_BLEND, out, tint, bricks2);
- }
+ const float *co = p->co;
+
+ float x = co[0];
+ float y = co[1];
+
+ int bricknum, rownum;
+ float offset = 0;
+ float ins_x, ins_y;
+ float tint;
+
+ float bricks1[4];
+ 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);
+
+ tex_input_rgba(bricks1, in[0], p, thread);
+ tex_input_rgba(bricks2, in[1], p, thread);
+ tex_input_rgba(mortar, in[2], p, thread);
+
+ rownum = (int)floor(y / row_height);
+
+ if (node->custom1 && node->custom2) {
+ brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */
+ offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */
+ }
+
+ bricknum = (int)floor((x + offset) / brick_width);
+
+ ins_x = (x + offset) - brick_width * bricknum;
+ ins_y = y - row_height * rownum;
+
+ tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias;
+ CLAMP(tint, 0.0f, 1.0f);
+
+ if (ins_x < mortar_thickness || ins_y < mortar_thickness ||
+ ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness)) {
+ copy_v4_v4(out, mortar);
+ }
+ else {
+ copy_v4_v4(out, bricks1);
+ ramp_blend(MA_RAMP_BLEND, out, tint, bricks2);
+ }
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_bricks(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
- node_type_init(&ntype, init);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
+ node_type_init(&ntype, init);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c
index 8cc40b7d5b0..33fc1a2c1f3 100644
--- a/source/blender/nodes/texture/nodes/node_texture_checker.c
+++ b/source/blender/nodes/texture/nodes/node_texture_checker.c
@@ -21,54 +21,58 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
#include <math.h>
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f },
- { SOCK_RGBA, 1, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f },
- { SOCK_FLOAT, 1, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_RGBA, 1, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f},
+ {SOCK_FLOAT, 1, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color") },
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float x = p->co[0];
- float y = p->co[1];
- float z = p->co[2];
- float sz = tex_input_value(in[2], p, thread);
+ float x = p->co[0];
+ float y = p->co[1];
+ float z = p->co[2];
+ float sz = tex_input_value(in[2], p, thread);
- /* 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));
+ /* 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));
- if ( (xi % 2 == yi % 2) == (zi % 2) ) {
- tex_input_rgba(out, in[0], p, thread);
- }
- else {
- tex_input_rgba(out, in[1], p, thread);
- }
+ if ((xi % 2 == yi % 2) == (zi % 2)) {
+ tex_input_rgba(out, in[0], p, thread);
+ }
+ else {
+ tex_input_rgba(out, in[1], p, thread);
+ }
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_checker(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, NODE_PREVIEW);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN, NODE_PREVIEW);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 3efc01d25d6..9f76c464c12 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -22,7 +22,6 @@
* \ingroup texnodes
*/
-
#include "DNA_node_types.h"
#include "BLI_utildefines.h"
@@ -38,37 +37,37 @@
static void copy_stack(bNodeStack *to, bNodeStack *from)
{
- if (to != from) {
- copy_v4_v4(to->vec, from->vec);
- to->data = from->data;
- to->datatype = from->datatype;
-
- /* tag as copy to prevent freeing */
- to->is_copy = 1;
- }
+ if (to != from) {
+ copy_v4_v4(to->vec, from->vec);
+ to->data = from->data;
+ to->datatype = from->datatype;
+
+ /* tag as copy to prevent freeing */
+ to->is_copy = 1;
+ }
}
/**** GROUP ****/
static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanceKey key)
{
- bNodeTree *ngroup = (bNodeTree *)node->id;
- void *exec;
+ bNodeTree *ngroup = (bNodeTree *)node->id;
+ void *exec;
- if (!ngroup)
- return NULL;
+ if (!ngroup)
+ return NULL;
- /* initialize the internal node tree execution */
- exec = ntreeTexBeginExecTree_internal(context, ngroup, key);
+ /* initialize the internal node tree execution */
+ exec = ntreeTexBeginExecTree_internal(context, ngroup, key);
- return exec;
+ return exec;
}
static void group_freeexec(void *nodedata)
{
- bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
+ bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
- ntreeTexEndExecTree_internal(gexec);
+ ntreeTexEndExecTree_internal(gexec);
}
/* Copy inputs to the internal stack.
@@ -76,99 +75,104 @@ static void group_freeexec(void *nodedata)
*/
static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack)
{
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNode *node;
- bNodeSocket *sock;
- bNodeStack *ns;
- int a;
-
- for (node = ngroup->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP_INPUT) {
- for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
- if (in[a]) { /* shouldn't need to check this [#36694] */
- ns = node_get_socket_stack(gstack, sock);
- if (ns) {
- copy_stack(ns, in[a]);
- }
- }
- }
- }
- }
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeStack *ns;
+ int a;
+
+ for (node = ngroup->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP_INPUT) {
+ for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
+ if (in[a]) { /* shouldn't need to check this [#36694] */
+ ns = node_get_socket_stack(gstack, sock);
+ if (ns) {
+ copy_stack(ns, in[a]);
+ }
+ }
+ }
+ }
+ }
}
/* Copy internal results to the external outputs.
*/
static void group_copy_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstack)
{
- bNodeTree *ngroup = (bNodeTree *)gnode->id;
- bNode *node;
- bNodeSocket *sock;
- bNodeStack *ns;
- int a;
-
- for (node = ngroup->nodes.first; node; node = node->next) {
- if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
- for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
- if (out[a]) { /* shouldn't need to check this [#36694] */
- ns = node_get_socket_stack(gstack, sock);
- if (ns) {
- copy_stack(out[a], ns);
- }
- }
- }
- break; /* only one active output node */
- }
- }
+ bNodeTree *ngroup = (bNodeTree *)gnode->id;
+ bNode *node;
+ bNodeSocket *sock;
+ bNodeStack *ns;
+ int a;
+
+ for (node = ngroup->nodes.first; node; node = node->next) {
+ if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
+ for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
+ if (out[a]) { /* shouldn't need to check this [#36694] */
+ ns = node_get_socket_stack(gstack, sock);
+ if (ns) {
+ copy_stack(out[a], ns);
+ }
+ }
+ }
+ break; /* only one active output node */
+ }
+ }
}
-static void group_execute(void *data, int thread, struct bNode *node, bNodeExecData *execdata, struct bNodeStack **in, struct bNodeStack **out)
+static void group_execute(void *data,
+ int thread,
+ struct bNode *node,
+ bNodeExecData *execdata,
+ struct bNodeStack **in,
+ struct bNodeStack **out)
{
- bNodeTreeExec *exec = execdata->data;
- bNodeThreadStack *nts;
+ bNodeTreeExec *exec = execdata->data;
+ bNodeThreadStack *nts;
- if (!exec)
- return;
+ if (!exec)
+ return;
- /* XXX same behavior as trunk: all nodes inside group are executed.
- * it's stupid, but just makes it work. compo redesign will do this better.
- */
- {
- bNode *inode;
- for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
- inode->need_exec = 1;
- }
+ /* XXX same behavior as trunk: all nodes inside group are executed.
+ * it's stupid, but just makes it work. compo redesign will do this better.
+ */
+ {
+ bNode *inode;
+ for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
+ inode->need_exec = 1;
+ }
- nts = ntreeGetThreadStack(exec, thread);
+ nts = ntreeGetThreadStack(exec, thread);
- group_copy_inputs(node, in, nts->stack);
- ntreeExecThreadNodes(exec, nts, data, thread);
- group_copy_outputs(node, out, nts->stack);
+ group_copy_inputs(node, in, nts->stack);
+ ntreeExecThreadNodes(exec, nts, data, thread);
+ group_copy_outputs(node, out, nts->stack);
- ntreeReleaseThreadStack(nts);
+ ntreeReleaseThreadStack(nts);
}
void register_node_type_tex_group(void)
{
- static bNodeType ntype;
-
- /* NB: cannot use sh_node_type_base for node group, because it would map the node type
- * to the shared NODE_GROUP integer type id.
- */
- node_type_base_custom(&ntype, "TextureNodeGroup", "Group", NODE_CLASS_GROUP, NODE_CONST_OUTPUT);
- ntype.type = NODE_GROUP;
- ntype.poll = tex_node_poll_default;
- ntype.poll_instance = node_group_poll_instance;
- ntype.insert_link = node_insert_link_default;
- ntype.update_internal_links = node_update_internal_links_default;
- ntype.ext.srna = RNA_struct_find("TextureNodeGroup");
- BLI_assert(ntype.ext.srna != NULL);
- RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
-
- node_type_socket_templates(&ntype, NULL, NULL);
- node_type_size(&ntype, 140, 60, 400);
- node_type_label(&ntype, node_group_label);
- node_type_update(&ntype, NULL, node_group_verify);
- node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
-
- nodeRegisterType(&ntype);
+ static bNodeType ntype;
+
+ /* NB: cannot use sh_node_type_base for node group, because it would map the node type
+ * to the shared NODE_GROUP integer type id.
+ */
+ node_type_base_custom(&ntype, "TextureNodeGroup", "Group", NODE_CLASS_GROUP, NODE_CONST_OUTPUT);
+ ntype.type = NODE_GROUP;
+ ntype.poll = tex_node_poll_default;
+ ntype.poll_instance = node_group_poll_instance;
+ ntype.insert_link = node_insert_link_default;
+ ntype.update_internal_links = node_update_internal_links_default;
+ ntype.ext.srna = RNA_struct_find("TextureNodeGroup");
+ BLI_assert(ntype.ext.srna != NULL);
+ RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
+
+ node_type_socket_templates(&ntype, NULL, NULL);
+ node_type_size(&ntype, 140, 60, 400);
+ node_type_label(&ntype, node_group_label);
+ node_type_update(&ntype, NULL, node_group_verify);
+ node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
+
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index 767e4aee03e..ae266451671 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.c
@@ -21,41 +21,45 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_FLOAT, 1, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED },
- { -1, 0, "" },
+ {SOCK_FLOAT, 1, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color") },
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- int i;
- for (i = 0; i < 4; i++)
- out[i] = tex_input_value(in[i], p, thread);
+ int i;
+ for (i = 0; i < 4; i++)
+ out[i] = tex_input_value(in[i], p, thread);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_compose(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_COMPOSE, "Combine RGBA", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c
index 8859e27cd6c..30911eae1a3 100644
--- a/source/blender/nodes/texture/nodes/node_texture_coord.c
+++ b/source/blender/nodes/texture/nodes/node_texture_coord.c
@@ -21,33 +21,38 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate outputs[] = {
- { SOCK_VECTOR, 0, N_("Coordinates") },
- { -1, 0, "" },
+ {SOCK_VECTOR, 0, N_("Coordinates")},
+ {-1, 0, ""},
};
-static void vectorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread))
+static void vectorfn(
+ float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **UNUSED(in), short UNUSED(thread))
{
- copy_v3_v3(out, p->co);
+ copy_v3_v3(out, p->co);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &vectorfn, data);
+ tex_output(node, execdata, in, out[0], &vectorfn, data);
}
void register_node_type_tex_coord(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0);
- node_type_socket_templates(&ntype, NULL, outputs);
- node_type_storage(&ntype, "", NULL, NULL);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT, 0);
+ node_type_socket_templates(&ntype, NULL, outputs);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index d0d387f3fa6..a57e2d8f35f 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -21,98 +21,104 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
/* **************** CURVE Time ******************** */
/* custom1 = sfra, custom2 = efra */
-static bNodeSocketTemplate time_outputs[] = {
- { SOCK_FLOAT, 0, N_("Value") },
- { -1, 0, "" }
-};
+static bNodeSocketTemplate time_outputs[] = {{SOCK_FLOAT, 0, N_("Value")}, {-1, 0, ""}};
-static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread))
+static void time_colorfn(
+ float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread))
{
- /* stack order output: fac */
- float fac = 0.0f;
+ /* stack order output: fac */
+ float fac = 0.0f;
- if (node->custom1 < node->custom2)
- fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
+ if (node->custom1 < node->custom2)
+ fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
- curvemapping_initialize(node->storage);
- fac = curvemapping_evaluateF(node->storage, 0, fac);
- out[0] = CLAMPIS(fac, 0.0f, 1.0f);
+ curvemapping_initialize(node->storage);
+ fac = curvemapping_evaluateF(node->storage, 0, fac);
+ out[0] = CLAMPIS(fac, 0.0f, 1.0f);
}
-static void time_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void time_exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &time_colorfn, data);
+ tex_output(node, execdata, in, out[0], &time_colorfn, data);
}
-
static void time_init(bNodeTree *UNUSED(ntree), bNode *node)
{
- node->custom1 = 1;
- node->custom2 = 250;
- node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
+ node->custom1 = 1;
+ node->custom2 = 250;
+ node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
}
void register_node_type_tex_curve_time(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, 0);
- node_type_socket_templates(&ntype, NULL, time_outputs);
- node_type_size_preset(&ntype, NODE_SIZE_LARGE);
- node_type_init(&ntype, time_init);
- node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
- node_type_exec(&ntype, node_initexec_curves, NULL, time_exec);
+ tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, 0);
+ node_type_socket_templates(&ntype, NULL, time_outputs);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
+ node_type_init(&ntype, time_init);
+ node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
+ node_type_exec(&ntype, node_initexec_curves, NULL, time_exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
/* **************** CURVE RGB ******************** */
static bNodeSocketTemplate rgb_inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate rgb_outputs[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, ""},
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- float cin[4];
- tex_input_rgba(cin, in[0], p, thread);
+ float cin[4];
+ tex_input_rgba(cin, in[0], p, thread);
- curvemapping_evaluateRGBF(node->storage, out, cin);
- out[3] = cin[3];
+ curvemapping_evaluateRGBF(node->storage, out, cin);
+ out[3] = cin[3];
}
-static void rgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void rgb_exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &rgb_colorfn, data);
+ tex_output(node, execdata, in, out[0], &rgb_colorfn, data);
}
static void rgb_init(bNodeTree *UNUSED(ntree), bNode *node)
{
- node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
+ node->storage = curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
}
void register_node_type_tex_curve_rgb(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0);
- node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs);
- node_type_size_preset(&ntype, NODE_SIZE_LARGE);
- node_type_init(&ntype, rgb_init);
- node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
- node_type_exec(&ntype, node_initexec_curves, NULL, rgb_exec);
+ tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
+ node_type_init(&ntype, rgb_init);
+ node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
+ node_type_exec(&ntype, node_initexec_curves, NULL, rgb_exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c
index e531eb6c816..999b2c30448 100644
--- a/source/blender/nodes/texture/nodes/node_texture_decompose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c
@@ -21,62 +21,66 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
#include <math.h>
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_FLOAT, 0, N_("Red") },
- { SOCK_FLOAT, 0, N_("Green") },
- { SOCK_FLOAT, 0, N_("Blue") },
- { SOCK_FLOAT, 0, N_("Alpha") },
- { -1, 0, "" },
+ {SOCK_FLOAT, 0, N_("Red")},
+ {SOCK_FLOAT, 0, N_("Green")},
+ {SOCK_FLOAT, 0, N_("Blue")},
+ {SOCK_FLOAT, 0, N_("Alpha")},
+ {-1, 0, ""},
};
static void valuefn_r(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- tex_input_rgba(out, in[0], p, thread);
- *out = out[0];
+ tex_input_rgba(out, in[0], p, thread);
+ *out = out[0];
}
static void valuefn_g(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- tex_input_rgba(out, in[0], p, thread);
- *out = out[1];
+ tex_input_rgba(out, in[0], p, thread);
+ *out = out[1];
}
static void valuefn_b(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- tex_input_rgba(out, in[0], p, thread);
- *out = out[2];
+ tex_input_rgba(out, in[0], p, thread);
+ *out = out[2];
}
static void valuefn_a(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- tex_input_rgba(out, in[0], p, thread);
- *out = out[3];
+ tex_input_rgba(out, in[0], p, thread);
+ *out = out[3];
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &valuefn_r, data);
- tex_output(node, execdata, in, out[1], &valuefn_g, data);
- tex_output(node, execdata, in, out[2], &valuefn_b, data);
- tex_output(node, execdata, in, out[3], &valuefn_a, data);
+ tex_output(node, execdata, in, out[0], &valuefn_r, data);
+ tex_output(node, execdata, in, out[1], &valuefn_g, data);
+ tex_output(node, execdata, in, out[2], &valuefn_b, data);
+ tex_output(node, execdata, in, out[3], &valuefn_a, data);
}
void register_node_type_tex_decompose(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE, "Separate RGBA", NODE_CLASS_OP_COLOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE, "Separate RGBA", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c
index fed8fe6b866..e7df8b3073a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_distance.c
+++ b/source/blender/nodes/texture/nodes/node_texture_distance.c
@@ -21,46 +21,50 @@
* \ingroup texnodes
*/
-
#include <math.h>
#include "BLI_math.h"
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_VECTOR, 1, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
- { SOCK_VECTOR, 1, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
- { -1, 0, "" },
+ {SOCK_VECTOR, 1, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
+ {SOCK_VECTOR, 1, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_FLOAT, 0, N_("Value") },
- { -1, 0, "" },
+ {SOCK_FLOAT, 0, N_("Value")},
+ {-1, 0, ""},
};
static void valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float co1[3], co2[3];
+ float co1[3], co2[3];
- tex_input_vec(co1, in[0], p, thread);
- tex_input_vec(co2, in[1], p, thread);
+ tex_input_vec(co1, in[0], p, thread);
+ tex_input_vec(co2, in[1], p, thread);
- *out = len_v3v3(co2, co1);
+ *out = len_v3v3(co2, co1);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &valuefn, data);
+ tex_output(node, execdata, in, out[0], &valuefn, data);
}
void register_node_type_tex_distance(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_storage(&ntype, "", NULL, NULL);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
index 8e4959bdf06..c4105083945 100644
--- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
+++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
@@ -21,77 +21,90 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
-
static bNodeSocketTemplate inputs[] = {
- { SOCK_FLOAT, 1, N_("Hue"), 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("Factor"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE },
- { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f },
- { -1, 0, "" },
+ {SOCK_FLOAT, 1, N_("Hue"), 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("Factor"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ {SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color") },
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
-static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat, float val, float *in, float fac)
+static void do_hue_sat_fac(
+ bNode *UNUSED(node), float *out, float hue, float sat, float val, float *in, float fac)
{
- if (fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) {
- float col[3], hsv[3], mfac = 1.0f - fac;
-
- rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
- hsv[0] += (hue - 0.5f);
- if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f;
- hsv[1] *= sat;
- if (hsv[1] > 1.0f) hsv[1] = 1.0f; else if (hsv[1] < 0.0f) hsv[1] = 0.0f;
- hsv[2] *= val;
- if (hsv[2] > 1.0f) hsv[2] = 1.0f; else if (hsv[2] < 0.0f) hsv[2] = 0.0f;
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
-
- out[0] = mfac * in[0] + fac * col[0];
- out[1] = mfac * in[1] + fac * col[1];
- out[2] = mfac * in[2] + fac * col[2];
- }
- else {
- copy_v4_v4(out, in);
- }
+ if (fac != 0 && (hue != 0.5f || sat != 1 || val != 1)) {
+ float col[3], hsv[3], mfac = 1.0f - fac;
+
+ rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
+ hsv[0] += (hue - 0.5f);
+ if (hsv[0] > 1.0f)
+ hsv[0] -= 1.0f;
+ else if (hsv[0] < 0.0f)
+ hsv[0] += 1.0f;
+ hsv[1] *= sat;
+ if (hsv[1] > 1.0f)
+ hsv[1] = 1.0f;
+ else if (hsv[1] < 0.0f)
+ hsv[1] = 0.0f;
+ hsv[2] *= val;
+ if (hsv[2] > 1.0f)
+ hsv[2] = 1.0f;
+ else if (hsv[2] < 0.0f)
+ hsv[2] = 0.0f;
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
+
+ out[0] = mfac * in[0] + fac * col[0];
+ out[1] = mfac * in[1] + fac * col[1];
+ out[2] = mfac * in[2] + fac * col[2];
+ }
+ else {
+ copy_v4_v4(out, in);
+ }
}
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- float hue = tex_input_value(in[0], p, thread);
- float sat = tex_input_value(in[1], p, thread);
- float val = tex_input_value(in[2], p, thread);
- float fac = tex_input_value(in[3], p, thread);
+ float hue = tex_input_value(in[0], p, thread);
+ float sat = tex_input_value(in[1], p, thread);
+ float val = tex_input_value(in[2], p, thread);
+ float fac = tex_input_value(in[3], p, thread);
- float col[4];
- tex_input_rgba(col, in[4], p, thread);
+ float col[4];
+ tex_input_rgba(col, in[4], p, thread);
- hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */
+ hue += 0.5f; /* [-0.5, 0.5] -> [0, 1] */
- do_hue_sat_fac(node, out, hue, sat, val, col, fac);
+ do_hue_sat_fac(node, out, hue, sat, val, col, fac);
- out[3] = col[3];
+ out[3] = col[3];
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_hue_sat(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index 1975a9df306..5c7b7a56d3a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -21,84 +21,94 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Image")},
+ {-1, 0, ""},
};
-static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread))
+static void colorfn(
+ float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread))
{
- float x = p->co[0];
- float y = p->co[1];
- Image *ima = (Image *)node->id;
- ImageUser *iuser = (ImageUser *)node->storage;
-
- if (ima) {
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
- if (ibuf) {
- float xsize, ysize;
- float xoff, yoff;
- int px, py;
-
- const float *result;
-
- xsize = ibuf->x / 2;
- ysize = ibuf->y / 2;
- xoff = yoff = -1;
-
- px = (int)( (x - xoff) * xsize);
- py = (int)( (y - yoff) * ysize);
-
- if ( (!xsize) || (!ysize) ) return;
-
- if (!ibuf->rect_float) {
- BLI_thread_lock(LOCK_IMAGE);
- if (!ibuf->rect_float)
- IMB_float_from_rect(ibuf);
- BLI_thread_unlock(LOCK_IMAGE);
- }
-
- while (px < 0) px += ibuf->x;
- while (py < 0) py += ibuf->y;
- while (px >= ibuf->x) px -= ibuf->x;
- while (py >= ibuf->y) py -= ibuf->y;
-
- result = ibuf->rect_float + py * ibuf->x * 4 + px * 4;
- copy_v4_v4(out, result);
-
- BKE_image_release_ibuf(ima, ibuf, NULL);
- }
- }
+ float x = p->co[0];
+ float y = p->co[1];
+ Image *ima = (Image *)node->id;
+ ImageUser *iuser = (ImageUser *)node->storage;
+
+ if (ima) {
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
+ if (ibuf) {
+ float xsize, ysize;
+ float xoff, yoff;
+ int px, py;
+
+ const float *result;
+
+ xsize = ibuf->x / 2;
+ ysize = ibuf->y / 2;
+ xoff = yoff = -1;
+
+ px = (int)((x - xoff) * xsize);
+ py = (int)((y - yoff) * ysize);
+
+ if ((!xsize) || (!ysize))
+ return;
+
+ if (!ibuf->rect_float) {
+ BLI_thread_lock(LOCK_IMAGE);
+ if (!ibuf->rect_float)
+ IMB_float_from_rect(ibuf);
+ BLI_thread_unlock(LOCK_IMAGE);
+ }
+
+ while (px < 0)
+ px += ibuf->x;
+ while (py < 0)
+ py += ibuf->y;
+ while (px >= ibuf->x)
+ px -= ibuf->x;
+ while (py >= ibuf->y)
+ py -= ibuf->y;
+
+ result = ibuf->rect_float + py * ibuf->x * 4 + px * 4;
+ copy_v4_v4(out, result);
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+ }
+ }
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
- ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
- node->storage = iuser;
- iuser->sfra = 1;
- iuser->ok = 1;
- iuser->flag |= IMA_ANIM_ALWAYS;
+ ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "node image user");
+ node->storage = iuser;
+ iuser->sfra = 1;
+ iuser->ok = 1;
+ iuser->flag |= IMA_ANIM_ALWAYS;
}
void register_node_type_tex_image(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_socket_templates(&ntype, NULL, outputs);
- node_type_init(&ntype, init);
- node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
- node_type_exec(&ntype, NULL, NULL, exec);
- node_type_label(&ntype, node_image_label);
+ tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW);
+ node_type_socket_templates(&ntype, NULL, outputs);
+ node_type_init(&ntype, init);
+ node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL, NULL, exec);
+ node_type_label(&ntype, node_image_label);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c
index 60cc135a8d4..7bc335849bc 100644
--- a/source/blender/nodes/texture/nodes/node_texture_invert.c
+++ b/source/blender/nodes/texture/nodes/node_texture_invert.c
@@ -21,47 +21,51 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
/* **************** INVERT ******************** */
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float col[4];
+ float col[4];
- tex_input_rgba(col, in[0], p, thread);
+ tex_input_rgba(col, in[0], p, thread);
- col[0] = 1.0f - col[0];
- col[1] = 1.0f - col[1];
- col[2] = 1.0f - col[2];
+ col[0] = 1.0f - col[0];
+ col[1] = 1.0f - col[1];
+ col[2] = 1.0f - col[2];
- copy_v3_v3(out, col);
- out[3] = col[3];
+ copy_v3_v3(out, col);
+ out[3] = col[3];
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_invert(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 45205b6eac0..8b934be3698 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -21,225 +21,206 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
-
/* **************** SCALAR MATH ******************** */
static bNodeSocketTemplate inputs[] = {
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
- { -1, 0, "" },
+ {SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_FLOAT, 0, N_("Value")},
- { -1, 0, "" },
+ {SOCK_FLOAT, 0, N_("Value")},
+ {-1, 0, ""},
};
static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- float in0 = tex_input_value(in[0], p, thread);
- float in1 = tex_input_value(in[1], p, thread);
-
- switch (node->custom1) {
-
- case NODE_MATH_ADD:
- *out = in0 + in1;
- break;
- case NODE_MATH_SUB:
- *out = in0 - in1;
- break;
- case NODE_MATH_MUL:
- *out = in0 * in1;
- break;
- case NODE_MATH_DIVIDE:
- {
- if (in1 == 0) /* We don't want to divide by zero. */
- *out = 0.0;
- else
- *out = in0 / in1;
- break;
- }
- case NODE_MATH_SIN:
- {
- *out = sinf(in0);
- break;
- }
- case NODE_MATH_COS:
- {
- *out = cosf(in0);
- break;
- }
- case NODE_MATH_TAN:
- {
- *out = tanf(in0);
- break;
- }
- case NODE_MATH_ASIN:
- {
- /* Can't do the impossible... */
- if (in0 <= 1 && in0 >= -1)
- *out = asinf(in0);
- else
- *out = 0.0;
- break;
- }
- case NODE_MATH_ACOS:
- {
- /* Can't do the impossible... */
- if (in0 <= 1 && in0 >= -1)
- *out = acosf(in0);
- else
- *out = 0.0;
- break;
- }
- case NODE_MATH_ATAN:
- {
- *out = atan(in0);
- break;
- }
- case NODE_MATH_POW:
- {
- /* Only raise negative numbers by full integers */
- if (in0 >= 0) {
- out[0] = pow(in0, in1);
- }
- else {
- float y_mod_1 = fmod(in1, 1);
- if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
- *out = pow(in0, floor(in1 + 0.5f));
- }
- else {
- *out = 0.0;
- }
- }
- break;
- }
- case NODE_MATH_LOG:
- {
- /* Don't want any imaginary numbers... */
- if (in0 > 0 && in1 > 0)
- *out = log(in0) / log(in1);
- else
- *out = 0.0;
- break;
- }
- case NODE_MATH_MIN:
- {
- if (in0 < in1)
- *out = in0;
- else
- *out = in1;
- break;
- }
- case NODE_MATH_MAX:
- {
- if (in0 > in1)
- *out = in0;
- else
- *out = in1;
- break;
- }
- case NODE_MATH_ROUND:
- {
- *out = (in0 < 0) ? (int)(in0 - 0.5f) : (int)(in0 + 0.5f);
- break;
- }
-
- case NODE_MATH_LESS:
- {
- if (in0 < in1)
- *out = 1.0f;
- else
- *out = 0.0f;
- break;
- }
-
- case NODE_MATH_GREATER:
- {
- if (in0 > in1)
- *out = 1.0f;
- else
- *out = 0.0f;
- break;
- }
-
- case NODE_MATH_MOD:
- {
- if (in1 == 0.0f)
- *out = 0.0f;
- else
- *out = fmod(in0, in1);
- break;
- }
-
- case NODE_MATH_ABS:
- {
- *out = fabsf(in0);
- break;
- }
-
- case NODE_MATH_ATAN2:
- {
- *out = atan2(in0, in1);
- break;
- }
-
- case NODE_MATH_FLOOR:
- {
- *out = floorf(in0);
- break;
- }
-
- case NODE_MATH_CEIL:
- {
- *out = ceilf(in0);
- break;
- }
-
- case NODE_MATH_FRACT:
- {
- *out = in0 - floorf(in0);
- break;
- }
-
- case NODE_MATH_SQRT:
- {
- if (in0 > 0.0f)
- *out = sqrtf(in0);
- else
- *out = 0.0f;
- break;
- }
-
- default:
- {
- BLI_assert(0);
- break;
- }
- }
-
- if (node->custom2 & SHD_MATH_CLAMP) {
- CLAMP(*out, 0.0f, 1.0f);
- }
+ float in0 = tex_input_value(in[0], p, thread);
+ float in1 = tex_input_value(in[1], p, thread);
+
+ switch (node->custom1) {
+
+ case NODE_MATH_ADD:
+ *out = in0 + in1;
+ break;
+ case NODE_MATH_SUB:
+ *out = in0 - in1;
+ break;
+ case NODE_MATH_MUL:
+ *out = in0 * in1;
+ break;
+ case NODE_MATH_DIVIDE: {
+ if (in1 == 0) /* We don't want to divide by zero. */
+ *out = 0.0;
+ else
+ *out = in0 / in1;
+ break;
+ }
+ case NODE_MATH_SIN: {
+ *out = sinf(in0);
+ break;
+ }
+ case NODE_MATH_COS: {
+ *out = cosf(in0);
+ break;
+ }
+ case NODE_MATH_TAN: {
+ *out = tanf(in0);
+ break;
+ }
+ case NODE_MATH_ASIN: {
+ /* Can't do the impossible... */
+ if (in0 <= 1 && in0 >= -1)
+ *out = asinf(in0);
+ else
+ *out = 0.0;
+ break;
+ }
+ case NODE_MATH_ACOS: {
+ /* Can't do the impossible... */
+ if (in0 <= 1 && in0 >= -1)
+ *out = acosf(in0);
+ else
+ *out = 0.0;
+ break;
+ }
+ case NODE_MATH_ATAN: {
+ *out = atan(in0);
+ break;
+ }
+ case NODE_MATH_POW: {
+ /* Only raise negative numbers by full integers */
+ if (in0 >= 0) {
+ out[0] = pow(in0, in1);
+ }
+ else {
+ float y_mod_1 = fmod(in1, 1);
+ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
+ *out = pow(in0, floor(in1 + 0.5f));
+ }
+ else {
+ *out = 0.0;
+ }
+ }
+ break;
+ }
+ case NODE_MATH_LOG: {
+ /* Don't want any imaginary numbers... */
+ if (in0 > 0 && in1 > 0)
+ *out = log(in0) / log(in1);
+ else
+ *out = 0.0;
+ break;
+ }
+ case NODE_MATH_MIN: {
+ if (in0 < in1)
+ *out = in0;
+ else
+ *out = in1;
+ break;
+ }
+ case NODE_MATH_MAX: {
+ if (in0 > in1)
+ *out = in0;
+ else
+ *out = in1;
+ break;
+ }
+ case NODE_MATH_ROUND: {
+ *out = (in0 < 0) ? (int)(in0 - 0.5f) : (int)(in0 + 0.5f);
+ break;
+ }
+
+ case NODE_MATH_LESS: {
+ if (in0 < in1)
+ *out = 1.0f;
+ else
+ *out = 0.0f;
+ break;
+ }
+
+ case NODE_MATH_GREATER: {
+ if (in0 > in1)
+ *out = 1.0f;
+ else
+ *out = 0.0f;
+ break;
+ }
+
+ case NODE_MATH_MOD: {
+ if (in1 == 0.0f)
+ *out = 0.0f;
+ else
+ *out = fmod(in0, in1);
+ break;
+ }
+
+ case NODE_MATH_ABS: {
+ *out = fabsf(in0);
+ break;
+ }
+
+ case NODE_MATH_ATAN2: {
+ *out = atan2(in0, in1);
+ break;
+ }
+
+ case NODE_MATH_FLOOR: {
+ *out = floorf(in0);
+ break;
+ }
+
+ case NODE_MATH_CEIL: {
+ *out = ceilf(in0);
+ break;
+ }
+
+ case NODE_MATH_FRACT: {
+ *out = in0 - floorf(in0);
+ break;
+ }
+
+ case NODE_MATH_SQRT: {
+ if (in0 > 0.0f)
+ *out = sqrtf(in0);
+ else
+ *out = 0.0f;
+ break;
+ }
+
+ default: {
+ BLI_assert(0);
+ break;
+ }
+ }
+
+ if (node->custom2 & SHD_MATH_CLAMP) {
+ CLAMP(*out, 0.0f, 1.0f);
+ }
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &valuefn, data);
+ tex_output(node, execdata, in, out[0], &valuefn, data);
}
void register_node_type_tex_math(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_label(&ntype, node_math_label);
- node_type_storage(&ntype, "", NULL, NULL);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_label(&ntype, node_math_label);
+ node_type_storage(&ntype, "", NULL, NULL);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
index 047e427f478..667b1317ea4 100644
--- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
@@ -21,53 +21,57 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
/* **************** MIX RGB ******************** */
static bNodeSocketTemplate inputs[] = {
- { SOCK_FLOAT, 1, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE },
- { SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f },
- { SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f },
- { -1, 0, "" },
+ {SOCK_FLOAT, 1, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ {SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f},
+ {SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color") },
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- float fac = tex_input_value(in[0], p, thread);
- float col1[4], col2[4];
+ float fac = tex_input_value(in[0], p, thread);
+ float col1[4], col2[4];
- tex_input_rgba(col1, in[1], p, thread);
- tex_input_rgba(col2, in[2], p, thread);
+ tex_input_rgba(col1, in[1], p, thread);
+ tex_input_rgba(col2, in[2], p, thread);
- /* use alpha */
- if (node->custom2 & 1)
- fac *= col2[3];
+ /* use alpha */
+ if (node->custom2 & 1)
+ fac *= col2[3];
- CLAMP(fac, 0.0f, 1.0f);
+ CLAMP(fac, 0.0f, 1.0f);
- copy_v4_v4(out, col1);
- ramp_blend(node->custom1, out, fac, col2);
+ copy_v4_v4(out, col1);
+ ramp_blend(node->custom1, out, fac, col2);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_mix_rgb(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_label(&ntype, node_blend_label);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_label(&ntype, node_blend_label);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index ff9226479c9..e44bea3ecac 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -21,147 +21,150 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
/* **************** COMPOSITE ******************** */
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION},
- { -1, 0, ""},
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION},
+ {-1, 0, ""},
};
/* applies to render pipeline */
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out))
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **UNUSED(out))
{
- TexCallData *cdata = (TexCallData *)data;
- TexResult *target = cdata->target;
-
- if (cdata->do_preview) {
- TexParams params;
- params_from_cdata(&params, cdata);
-
- if (in[1] && in[1]->hasinput && !in[0]->hasinput)
- tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
- else
- tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
- tex_do_preview(execdata->preview, params.co, &target->tr, cdata->do_manage);
- }
- else {
- /* 0 means don't care, so just use first */
- if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) {
- TexParams params;
- params_from_cdata(&params, cdata);
-
- tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
-
- target->tin = (target->tr + target->tg + target->tb) / 3.0f;
- target->talpha = true;
-
- if (target->nor) {
- if (in[1] && in[1]->hasinput)
- tex_input_vec(target->nor, in[1], &params, cdata->thread);
- else
- target->nor = NULL;
- }
- }
- }
+ TexCallData *cdata = (TexCallData *)data;
+ TexResult *target = cdata->target;
+
+ if (cdata->do_preview) {
+ TexParams params;
+ params_from_cdata(&params, cdata);
+
+ if (in[1] && in[1]->hasinput && !in[0]->hasinput)
+ tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
+ else
+ tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
+ tex_do_preview(execdata->preview, params.co, &target->tr, cdata->do_manage);
+ }
+ else {
+ /* 0 means don't care, so just use first */
+ if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) {
+ TexParams params;
+ params_from_cdata(&params, cdata);
+
+ tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
+
+ target->tin = (target->tr + target->tg + target->tb) / 3.0f;
+ target->talpha = true;
+
+ if (target->nor) {
+ if (in[1] && in[1]->hasinput)
+ tex_input_vec(target->nor, in[1], &params, cdata->thread);
+ else
+ target->nor = NULL;
+ }
+ }
+ }
}
static void unique_name(bNode *node)
{
- TexNodeOutput *tno = (TexNodeOutput *)node->storage;
- char new_name[sizeof(tno->name)];
- int new_len = 0;
- int suffix;
- bNode *i;
- const char *name = tno->name;
-
- new_name[0] = '\0';
- i = node;
- while (i->prev) i = i->prev;
- for (; i; i = i->next) {
- if (i == node ||
- i->type != TEX_NODE_OUTPUT ||
- !STREQ(name, ((TexNodeOutput *)(i->storage))->name))
- {
- continue;
- }
-
- if (new_name[0] == '\0') {
- int len = strlen(name);
- if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) {
- new_len = len;
- }
- else {
- suffix = 0;
- new_len = len + 4;
- if (new_len > (sizeof(tno->name) - 1))
- new_len = (sizeof(tno->name) - 1);
- }
-
- BLI_strncpy(new_name, name, sizeof(tno->name));
- name = new_name;
- }
- sprintf(new_name + new_len - 4, ".%03d", ++suffix);
- }
-
- if (new_name[0] != '\0') {
- BLI_strncpy(tno->name, new_name, sizeof(tno->name));
- }
+ TexNodeOutput *tno = (TexNodeOutput *)node->storage;
+ char new_name[sizeof(tno->name)];
+ int new_len = 0;
+ int suffix;
+ bNode *i;
+ const char *name = tno->name;
+
+ new_name[0] = '\0';
+ i = node;
+ while (i->prev)
+ i = i->prev;
+ for (; i; i = i->next) {
+ if (i == node || i->type != TEX_NODE_OUTPUT ||
+ !STREQ(name, ((TexNodeOutput *)(i->storage))->name)) {
+ continue;
+ }
+
+ if (new_name[0] == '\0') {
+ int len = strlen(name);
+ if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) {
+ new_len = len;
+ }
+ else {
+ suffix = 0;
+ new_len = len + 4;
+ if (new_len > (sizeof(tno->name) - 1))
+ new_len = (sizeof(tno->name) - 1);
+ }
+
+ BLI_strncpy(new_name, name, sizeof(tno->name));
+ name = new_name;
+ }
+ sprintf(new_name + new_len - 4, ".%03d", ++suffix);
+ }
+
+ if (new_name[0] != '\0') {
+ BLI_strncpy(tno->name, new_name, sizeof(tno->name));
+ }
}
static void assign_index(struct bNode *node)
{
- bNode *tnode;
- int index = 1;
+ bNode *tnode;
+ int index = 1;
- tnode = node;
- while (tnode->prev)
- tnode = tnode->prev;
+ tnode = node;
+ while (tnode->prev)
+ tnode = tnode->prev;
check_index:
- for (; tnode; tnode = tnode->next)
- if (tnode->type == TEX_NODE_OUTPUT && tnode != node)
- if (tnode->custom1 == index) {
- index++;
- goto check_index;
- }
-
- node->custom1 = index;
+ for (; tnode; tnode = tnode->next)
+ if (tnode->type == TEX_NODE_OUTPUT && tnode != node)
+ if (tnode->custom1 == index) {
+ index++;
+ goto check_index;
+ }
+
+ node->custom1 = index;
}
static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
- TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
- node->storage = tno;
+ TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
+ node->storage = tno;
- strcpy(tno->name, "Default");
- unique_name(node);
- assign_index(node);
+ strcpy(tno->name, "Default");
+ unique_name(node);
+ assign_index(node);
}
static void copy(bNodeTree *dest_ntree, bNode *dest_node, bNode *src_node)
{
- node_copy_standard_storage(dest_ntree, dest_node, src_node);
- unique_name(dest_node);
- assign_index(dest_node);
+ node_copy_standard_storage(dest_ntree, dest_node, src_node);
+ unique_name(dest_node);
+ assign_index(dest_node);
}
void register_node_type_tex_output(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW);
- node_type_socket_templates(&ntype, inputs, NULL);
- node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
- node_type_init(&ntype, init);
- node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW);
+ node_type_socket_templates(&ntype, inputs, NULL);
+ node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
+ node_type_init(&ntype, init);
+ node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy);
+ node_type_exec(&ntype, NULL, NULL, exec);
- /* Do not allow muting output. */
- node_type_internal_links(&ntype, NULL);
+ /* Do not allow muting output. */
+ node_type_internal_links(&ntype, NULL);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index 34be50aaeec..8024ccdc631 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -21,7 +21,6 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
@@ -31,287 +30,278 @@
* In this file: wrappers to use procedural textures as nodes
*/
-
static bNodeSocketTemplate outputs_both[] = {
- { SOCK_RGBA, 0, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f },
- { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION },
- { -1, 0, "" }
-};
-static bNodeSocketTemplate outputs_color_only[] = {
- { SOCK_RGBA, 0, N_("Color") },
- { -1, 0, "" }
-};
+ {SOCK_RGBA, 0, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION},
+ {-1, 0, ""}};
+static bNodeSocketTemplate outputs_color_only[] = {{SOCK_RGBA, 0, N_("Color")}, {-1, 0, ""}};
/* Inputs common to all, #defined because nodes will need their own inputs too */
#define I 2 /* count */
#define COMMON_INPUTS \
- { SOCK_RGBA, 1, "Color 1", 0.0f, 0.0f, 0.0f, 1.0f }, \
- { SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f }
+ {SOCK_RGBA, 1, "Color 1", 0.0f, 0.0f, 0.0f, 1.0f}, \
+ { \
+ SOCK_RGBA, 1, "Color 2", 1.0f, 1.0f, 1.0f, 1.0f \
+ }
/* Calls multitex and copies the result to the outputs. Called by xxx_exec, which handles inputs. */
-static void do_proc(float *result, TexParams *p, const float col1[4], const float col2[4], char is_normal, Tex *tex, const short thread)
+static void do_proc(float *result,
+ TexParams *p,
+ const float col1[4],
+ const float col2[4],
+ char is_normal,
+ Tex *tex,
+ const short thread)
{
- TexResult texres;
- int textype;
-
- if (is_normal) {
- texres.nor = result;
- }
- else
- texres.nor = NULL;
-
- textype = multitex_nodes(tex, p->co, p->dxt, p->dyt, p->osatex,
- &texres, thread, 0, p->mtex, NULL);
-
- if (is_normal)
- return;
-
- if (textype & TEX_RGB) {
- copy_v4_v4(result, &texres.tr);
- }
- else {
- copy_v4_v4(result, col1);
- ramp_blend(MA_RAMP_BLEND, result, texres.tin, col2);
- }
+ TexResult texres;
+ int textype;
+
+ if (is_normal) {
+ texres.nor = result;
+ }
+ else
+ texres.nor = NULL;
+
+ textype = multitex_nodes(
+ tex, p->co, p->dxt, p->dyt, p->osatex, &texres, thread, 0, p->mtex, NULL);
+
+ if (is_normal)
+ return;
+
+ if (textype & TEX_RGB) {
+ copy_v4_v4(result, &texres.tr);
+ }
+ else {
+ copy_v4_v4(result, col1);
+ ramp_blend(MA_RAMP_BLEND, result, texres.tin, col2);
+ }
}
-typedef void (*MapFn) (Tex *tex, bNodeStack **in, TexParams *p, const short thread);
+typedef void (*MapFn)(Tex *tex, bNodeStack **in, TexParams *p, const short thread);
-static void texfn(
- float *result,
- TexParams *p,
- bNode *node,
- bNodeStack **in,
- char is_normal,
- MapFn map_inputs,
- short thread)
+static void texfn(float *result,
+ TexParams *p,
+ bNode *node,
+ bNodeStack **in,
+ char is_normal,
+ MapFn map_inputs,
+ short thread)
{
- Tex tex = *((Tex *)(node->storage));
- float col1[4], col2[4];
- tex_input_rgba(col1, in[0], p, thread);
- tex_input_rgba(col2, in[1], p, thread);
+ Tex tex = *((Tex *)(node->storage));
+ float col1[4], col2[4];
+ tex_input_rgba(col1, in[0], p, thread);
+ tex_input_rgba(col2, in[1], p, thread);
- map_inputs(&tex, in, p, thread);
+ map_inputs(&tex, in, p, thread);
- do_proc(result, p, col1, col2, is_normal, &tex, thread);
+ do_proc(result, p, col1, col2, is_normal, &tex, thread);
}
static int count_outputs(bNode *node)
{
- bNodeSocket *sock;
- int num = 0;
- for (sock = node->outputs.first; sock; sock = sock->next) {
- num++;
- }
- return num;
+ bNodeSocket *sock;
+ int num = 0;
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ num++;
+ }
+ return num;
}
/* Boilerplate generators */
#define ProcNoInputs(name) \
- static void name##_map_inputs(Tex *UNUSED(tex), bNodeStack **UNUSED(in), TexParams *UNUSED(p), short UNUSED(thread)) \
- {}
+ static void name##_map_inputs( \
+ Tex *UNUSED(tex), bNodeStack **UNUSED(in), TexParams *UNUSED(p), short UNUSED(thread)) \
+ { \
+ }
#define ProcDef(name) \
- static void name##_colorfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \
- { \
- texfn(result, p, node, in, 0, &name##_map_inputs, thread); \
- } \
- static void name##_normalfn(float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \
- { \
- texfn(result, p, node, in, 1, &name##_map_inputs, thread); \
- } \
- static void name##_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) \
- { \
- int outs = count_outputs(node); \
- if (outs >= 1) tex_output(node, execdata, in, out[0], &name##_colorfn, data); \
- if (outs >= 2) tex_output(node, execdata, in, out[1], &name##_normalfn, data); \
- }
-
+ static void name##_colorfn( \
+ float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \
+ { \
+ texfn(result, p, node, in, 0, &name##_map_inputs, thread); \
+ } \
+ static void name##_normalfn( \
+ float *result, TexParams *p, bNode *node, bNodeStack **in, short thread) \
+ { \
+ texfn(result, p, node, in, 1, &name##_map_inputs, thread); \
+ } \
+ static void name##_exec(void *data, \
+ int UNUSED(thread), \
+ bNode *node, \
+ bNodeExecData *execdata, \
+ bNodeStack **in, \
+ bNodeStack **out) \
+ { \
+ int outs = count_outputs(node); \
+ if (outs >= 1) \
+ tex_output(node, execdata, in, out[0], &name##_colorfn, data); \
+ if (outs >= 2) \
+ tex_output(node, execdata, in, out[1], &name##_normalfn, data); \
+ }
/* --- VORONOI -- */
static bNodeSocketTemplate voronoi_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("W1"), 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("W3"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("W4"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE },
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("W1"), 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("W3"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("W4"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE},
- { SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, 10.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 4.0f, PROP_UNSIGNED },
+ {SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.01f, 10.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 4.0f, PROP_UNSIGNED},
- { -1, 0, "" }
-};
+ {-1, 0, ""}};
static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->vn_w1 = tex_input_value(in[I + 0], p, thread);
- tex->vn_w2 = tex_input_value(in[I + 1], p, thread);
- tex->vn_w3 = tex_input_value(in[I + 2], p, thread);
- tex->vn_w4 = tex_input_value(in[I + 3], p, thread);
+ tex->vn_w1 = tex_input_value(in[I + 0], p, thread);
+ tex->vn_w2 = tex_input_value(in[I + 1], p, thread);
+ tex->vn_w3 = tex_input_value(in[I + 2], p, thread);
+ tex->vn_w4 = tex_input_value(in[I + 3], p, thread);
- tex->ns_outscale = tex_input_value(in[I + 4], p, thread);
- tex->noisesize = tex_input_value(in[I + 5], p, thread);
+ tex->ns_outscale = tex_input_value(in[I + 4], p, thread);
+ tex->noisesize = tex_input_value(in[I + 5], p, thread);
}
ProcDef(voronoi)
-/* --- BLEND -- */
-static bNodeSocketTemplate blend_inputs[] = {
- COMMON_INPUTS,
- { -1, 0, "" }
-};
-ProcNoInputs(blend)
-ProcDef(blend)
-
-/* -- MAGIC -- */
-static bNodeSocketTemplate magic_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- BLEND -- */
+ static bNodeSocketTemplate blend_inputs[] = {COMMON_INPUTS, {-1, 0, ""}};
+ProcNoInputs(blend) ProcDef(blend)
+
+ /* -- MAGIC -- */
+ static bNodeSocketTemplate magic_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->turbul = tex_input_value(in[I + 0], p, thread);
+ tex->turbul = tex_input_value(in[I + 0], p, thread);
}
ProcDef(magic)
-/* --- MARBLE --- */
-static bNodeSocketTemplate marble_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- MARBLE --- */
+ static bNodeSocketTemplate marble_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->noisesize = tex_input_value(in[I + 0], p, thread);
- tex->turbul = tex_input_value(in[I + 1], p, thread);
+ tex->noisesize = tex_input_value(in[I + 0], p, thread);
+ tex->turbul = tex_input_value(in[I + 1], p, thread);
}
ProcDef(marble)
-/* --- CLOUDS --- */
-static bNodeSocketTemplate clouds_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- CLOUDS --- */
+ static bNodeSocketTemplate clouds_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->noisesize = tex_input_value(in[I + 0], p, thread);
+ tex->noisesize = tex_input_value(in[I + 0], p, thread);
}
ProcDef(clouds)
-/* --- DISTORTED NOISE --- */
-static bNodeSocketTemplate distnoise_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Distortion"), 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- DISTORTED NOISE --- */
+ static bNodeSocketTemplate distnoise_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Distortion"), 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->noisesize = tex_input_value(in[I + 0], p, thread);
- tex->dist_amount = tex_input_value(in[I + 1], p, thread);
+ tex->noisesize = tex_input_value(in[I + 0], p, thread);
+ tex->dist_amount = tex_input_value(in[I + 1], p, thread);
}
ProcDef(distnoise)
-/* --- WOOD --- */
-static bNodeSocketTemplate wood_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- WOOD --- */
+ static bNodeSocketTemplate wood_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->noisesize = tex_input_value(in[I + 0], p, thread);
- tex->turbul = tex_input_value(in[I + 1], p, thread);
+ tex->noisesize = tex_input_value(in[I + 0], p, thread);
+ tex->turbul = tex_input_value(in[I + 1], p, thread);
}
ProcDef(wood)
-/* --- MUSGRAVE --- */
-static bNodeSocketTemplate musgrave_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Octaves"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f, PROP_UNSIGNED },
-
- { SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- MUSGRAVE --- */
+ static bNodeSocketTemplate musgrave_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Octaves"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f, PROP_UNSIGNED},
+
+ {SOCK_FLOAT, 1, N_("iScale"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->mg_H = tex_input_value(in[I + 0], p, thread);
- tex->mg_lacunarity = tex_input_value(in[I + 1], p, thread);
- tex->mg_octaves = tex_input_value(in[I + 2], p, thread);
- tex->ns_outscale = tex_input_value(in[I + 3], p, thread);
- tex->noisesize = tex_input_value(in[I + 4], p, thread);
+ tex->mg_H = tex_input_value(in[I + 0], p, thread);
+ tex->mg_lacunarity = tex_input_value(in[I + 1], p, thread);
+ tex->mg_octaves = tex_input_value(in[I + 2], p, thread);
+ tex->ns_outscale = tex_input_value(in[I + 3], p, thread);
+ tex->noisesize = tex_input_value(in[I + 4], p, thread);
}
ProcDef(musgrave)
-/* --- NOISE --- */
-static bNodeSocketTemplate noise_inputs[] = {
- COMMON_INPUTS,
- { -1, 0, "" }
-};
-ProcNoInputs(noise)
-ProcDef(noise)
-
-/* --- STUCCI --- */
-static bNodeSocketTemplate stucci_inputs[] = {
- COMMON_INPUTS,
- { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED },
- { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED },
- { -1, 0, "" }
-};
+ /* --- NOISE --- */
+ static bNodeSocketTemplate noise_inputs[] = {COMMON_INPUTS, {-1, 0, ""}};
+ProcNoInputs(noise) ProcDef(noise)
+
+ /* --- STUCCI --- */
+ static bNodeSocketTemplate stucci_inputs[] = {
+ COMMON_INPUTS,
+ {SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED},
+ {SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED},
+ {-1, 0, ""}};
static void stucci_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thread)
{
- tex->noisesize = tex_input_value(in[I + 0], p, thread);
- tex->turbul = tex_input_value(in[I + 1], p, thread);
+ tex->noisesize = tex_input_value(in[I + 0], p, thread);
+ tex->turbul = tex_input_value(in[I + 1], p, thread);
}
ProcDef(stucci)
-/* --- */
+ /* --- */
-static void init(bNodeTree *UNUSED(ntree), bNode *node)
+ static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
- Tex *tex = MEM_callocN(sizeof(Tex), "Tex");
- node->storage = tex;
+ Tex *tex = MEM_callocN(sizeof(Tex), "Tex");
+ node->storage = tex;
- BKE_texture_default(tex);
- tex->type = node->type - TEX_NODE_PROC;
-
- if (tex->type == TEX_WOOD)
- tex->stype = TEX_BANDNOISE;
+ BKE_texture_default(tex);
+ tex->type = node->type - TEX_NODE_PROC;
+ if (tex->type == TEX_WOOD)
+ tex->stype = TEX_BANDNOISE;
}
/* Node type definitions */
#define TexDef(TEXTYPE, outputs, name, Name) \
-void register_node_type_tex_proc_##name(void) \
-{ \
- static bNodeType ntype; \
- \
- tex_node_type_base(&ntype, TEX_NODE_PROC+TEXTYPE, Name, NODE_CLASS_TEXTURE, NODE_PREVIEW); \
- node_type_socket_templates(&ntype, name##_inputs, outputs); \
- node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); \
- node_type_init(&ntype, init); \
- node_type_storage(&ntype, "Tex", node_free_standard_storage, node_copy_standard_storage); \
- node_type_exec(&ntype, NULL, NULL, name##_exec); \
- \
- nodeRegisterType(&ntype); \
-}
+ void register_node_type_tex_proc_##name(void) \
+ { \
+ static bNodeType ntype; \
+\
+ tex_node_type_base(&ntype, TEX_NODE_PROC + TEXTYPE, Name, NODE_CLASS_TEXTURE, NODE_PREVIEW); \
+ node_type_socket_templates(&ntype, name##_inputs, outputs); \
+ node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); \
+ node_type_init(&ntype, init); \
+ node_type_storage(&ntype, "Tex", node_free_standard_storage, node_copy_standard_storage); \
+ node_type_exec(&ntype, NULL, NULL, name##_exec); \
+\
+ nodeRegisterType(&ntype); \
+ }
#define C outputs_color_only
#define CV outputs_both
-TexDef(TEX_VORONOI, CV, voronoi, "Voronoi" )
-TexDef(TEX_BLEND, C, blend, "Blend" )
-TexDef(TEX_MAGIC, C, magic, "Magic" )
-TexDef(TEX_MARBLE, CV, marble, "Marble" )
-TexDef(TEX_CLOUDS, CV, clouds, "Clouds" )
-TexDef(TEX_WOOD, CV, wood, "Wood" )
-TexDef(TEX_MUSGRAVE, CV, musgrave, "Musgrave" )
-TexDef(TEX_NOISE, C, noise, "Noise" )
-TexDef(TEX_STUCCI, CV, stucci, "Stucci" )
-TexDef(TEX_DISTNOISE, CV, distnoise, "Distorted Noise" )
+TexDef(TEX_VORONOI, CV, voronoi, "Voronoi") TexDef(TEX_BLEND, C, blend, "Blend")
+ TexDef(TEX_MAGIC, C, magic, "Magic") TexDef(TEX_MARBLE, CV, marble, "Marble")
+ TexDef(TEX_CLOUDS, CV, clouds, "Clouds") TexDef(TEX_WOOD, CV, wood, "Wood")
+ TexDef(TEX_MUSGRAVE, CV, musgrave, "Musgrave") TexDef(TEX_NOISE, C, noise, "Noise")
+ TexDef(TEX_STUCCI, CV, stucci, "Stucci")
+ TexDef(TEX_DISTNOISE, CV, distnoise, "Distorted Noise")
diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c
index b8dfc9cb608..a7f348076ac 100644
--- a/source/blender/nodes/texture/nodes/node_texture_rotate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c
@@ -21,79 +21,83 @@
* \ingroup texnodes
*/
-
#include <math.h>
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Turns"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE },
- { SOCK_VECTOR, 1, N_("Axis"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_FLOAT, 1, N_("Turns"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE},
+ {SOCK_VECTOR, 1, N_("Axis"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void rotate(float new_co[3], float a, float ax[3], const float co[3])
{
- float para[3];
- float perp[3];
- float cp[3];
+ float para[3];
+ float perp[3];
+ float cp[3];
- float cos_a = cosf(a * (float)(2 * M_PI));
- float sin_a = sinf(a * (float)(2 * M_PI));
+ float cos_a = cosf(a * (float)(2 * M_PI));
+ float sin_a = sinf(a * (float)(2 * M_PI));
- // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina
+ // x' = xcosa + n(n.x)(1-cosa) + (x*n)sina
- mul_v3_v3fl(perp, co, cos_a);
- mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a));
+ mul_v3_v3fl(perp, co, cos_a);
+ mul_v3_v3fl(para, ax, dot_v3v3(co, ax) * (1 - cos_a));
- cross_v3_v3v3(cp, ax, co);
- mul_v3_fl(cp, sin_a);
+ cross_v3_v3v3(cp, ax, co);
+ mul_v3_fl(cp, sin_a);
- new_co[0] = para[0] + perp[0] + cp[0];
- new_co[1] = para[1] + perp[1] + cp[1];
- new_co[2] = para[2] + perp[2] + cp[2];
+ new_co[0] = para[0] + perp[0] + cp[0];
+ new_co[1] = para[1] + perp[1] + cp[1];
+ new_co[2] = para[2] + perp[2] + cp[2];
}
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float new_co[3], new_dxt[3], new_dyt[3], a, ax[3];
-
- a = tex_input_value(in[1], p, thread);
- tex_input_vec(ax, in[2], p, thread);
-
- rotate(new_co, a, ax, p->co);
- if (p->osatex) {
- rotate(new_dxt, a, ax, p->dxt);
- rotate(new_dyt, a, ax, p->dyt);
- }
-
- {
- TexParams np = *p;
- np.co = new_co;
- np.dxt = new_dxt;
- np.dyt = new_dyt;
- tex_input_rgba(out, in[0], &np, thread);
- }
+ float new_co[3], new_dxt[3], new_dyt[3], a, ax[3];
+
+ a = tex_input_value(in[1], p, thread);
+ tex_input_vec(ax, in[2], p, thread);
+
+ rotate(new_co, a, ax, p->co);
+ if (p->osatex) {
+ rotate(new_dxt, a, ax, p->dxt);
+ rotate(new_dyt, a, ax, p->dyt);
+ }
+
+ {
+ TexParams np = *p;
+ np.co = new_co;
+ np.dxt = new_dxt;
+ np.dyt = new_dyt;
+ tex_input_rgba(out, in[0], &np, thread);
+ }
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_rotate(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c
index e7e255ed7ef..61e81c1ed02 100644
--- a/source/blender/nodes/texture/nodes/node_texture_scale.c
+++ b/source/blender/nodes/texture/nodes/node_texture_scale.c
@@ -21,52 +21,56 @@
* \ingroup texnodes
*/
-
#include <math.h>
#include "node_texture_util.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f },
- { SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 0.0f, -10.0f, 10.0f, PROP_XYZ },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 0.0f, -10.0f, 10.0f, PROP_XYZ},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float scale[3], new_co[3], new_dxt[3], new_dyt[3];
- TexParams np = *p;
+ float scale[3], new_co[3], new_dxt[3], new_dyt[3];
+ TexParams np = *p;
- np.co = new_co;
- np.dxt = new_dxt;
- np.dyt = new_dyt;
+ np.co = new_co;
+ np.dxt = new_dxt;
+ np.dyt = new_dyt;
- tex_input_vec(scale, in[1], p, thread);
+ tex_input_vec(scale, in[1], p, thread);
- mul_v3_v3v3(new_co, p->co, scale);
- if (p->osatex) {
- mul_v3_v3v3(new_dxt, p->dxt, scale);
- mul_v3_v3v3(new_dyt, p->dyt, scale);
- }
+ mul_v3_v3v3(new_co, p->co, scale);
+ if (p->osatex) {
+ mul_v3_v3v3(new_dxt, p->dxt, scale);
+ mul_v3_v3v3(new_dyt, p->dyt, scale);
+ }
- tex_input_rgba(out, in[0], &np, thread);
+ tex_input_rgba(out, in[0], &np, thread);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_scale(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c
index 791e0fab1fb..342807d3142 100644
--- a/source/blender/nodes/texture/nodes/node_texture_texture.c
+++ b/source/blender/nodes/texture/nodes/node_texture_texture.c
@@ -21,79 +21,82 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
#include "RE_shader_ext.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f },
- { SOCK_RGBA, 1, N_("Color2"), 0.0f, 0.0f, 0.0f, 1.0f },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f},
+ {SOCK_RGBA, 1, N_("Color2"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color") },
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- Tex *nodetex = (Tex *)node->id;
- static float red[] = {1, 0, 0, 1};
- static float white[] = {1, 1, 1, 1};
- float co[3], dxt[3], dyt[3];
-
- copy_v3_v3(co, p->co);
- if (p->osatex) {
- copy_v3_v3(dxt, p->dxt);
- copy_v3_v3(dyt, p->dyt);
- }
- else {
- zero_v3(dxt);
- zero_v3(dyt);
- }
-
- if (node->custom2 || node->need_exec == 0) {
- /* this node refers to its own texture tree! */
- copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red);
- }
- else if (nodetex) {
- TexResult texres;
- int textype;
- float nor[] = {0, 0, 0};
- float col1[4], col2[4];
-
- tex_input_rgba(col1, in[0], p, thread);
- tex_input_rgba(col2, in[1], p, thread);
-
- texres.nor = nor;
- textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex,
- &texres, thread, 0, p->mtex, NULL);
-
- if (textype & TEX_RGB) {
- copy_v4_v4(out, &texres.tr);
- }
- else {
- copy_v4_v4(out, col1);
- ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2);
- }
- }
+ Tex *nodetex = (Tex *)node->id;
+ static float red[] = {1, 0, 0, 1};
+ static float white[] = {1, 1, 1, 1};
+ float co[3], dxt[3], dyt[3];
+
+ copy_v3_v3(co, p->co);
+ if (p->osatex) {
+ copy_v3_v3(dxt, p->dxt);
+ copy_v3_v3(dyt, p->dyt);
+ }
+ else {
+ zero_v3(dxt);
+ zero_v3(dyt);
+ }
+
+ if (node->custom2 || node->need_exec == 0) {
+ /* this node refers to its own texture tree! */
+ copy_v4_v4(out, (fabsf(co[0] - co[1]) < 0.01f) ? white : red);
+ }
+ else if (nodetex) {
+ TexResult texres;
+ int textype;
+ float nor[] = {0, 0, 0};
+ float col1[4], col2[4];
+
+ tex_input_rgba(col1, in[0], p, thread);
+ tex_input_rgba(col2, in[1], p, thread);
+
+ texres.nor = nor;
+ textype = multitex_nodes(nodetex, co, dxt, dyt, p->osatex, &texres, thread, 0, p->mtex, NULL);
+
+ if (textype & TEX_RGB) {
+ copy_v4_v4(out, &texres.tr);
+ }
+ else {
+ copy_v4_v4(out, col1);
+ ramp_blend(MA_RAMP_BLEND, out, texres.tin, col2);
+ }
+ }
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_texture(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT, NODE_PREVIEW);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c
index d4fc045a383..c53077d792b 100644
--- a/source/blender/nodes/texture/nodes/node_texture_translate.c
+++ b/source/blender/nodes/texture/nodes/node_texture_translate.c
@@ -21,48 +21,52 @@
* \ingroup texnodes
*/
-
#include <math.h>
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
- { SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
+ {SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float offset[3], new_co[3];
- TexParams np = *p;
- np.co = new_co;
+ float offset[3], new_co[3];
+ TexParams np = *p;
+ np.co = new_co;
- tex_input_vec(offset, in[1], p, thread);
+ tex_input_vec(offset, in[1], p, thread);
- new_co[0] = p->co[0] + offset[0];
- new_co[1] = p->co[1] + offset[1];
- new_co[2] = p->co[2] + offset[2];
+ new_co[0] = p->co[0] + offset[0];
+ new_co[1] = p->co[1] + offset[1];
+ new_co[2] = p->co[2] + offset[2];
- tex_input_rgba(out, in[0], &np, thread);
+ tex_input_rgba(out, in[0], &np, thread);
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+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_output(node, execdata, in, out[0], &colorfn, data);
}
void register_node_type_tex_translate(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c
index ea09b9e28ae..1a341b3129c 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.c
@@ -21,64 +21,68 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
static bNodeSocketTemplate inputs[] = {
- { SOCK_FLOAT, 1, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE },
- { SOCK_FLOAT, 1, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED },
- { -1, 0, "" },
+ {SOCK_FLOAT, 1, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
+ {SOCK_FLOAT, 1, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { SOCK_VECTOR, 0, N_("Normal") },
- { -1, 0, "" },
+ {SOCK_VECTOR, 0, N_("Normal")},
+ {-1, 0, ""},
};
static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float new_co[3];
- const float *co = p->co;
+ float new_co[3];
+ const float *co = p->co;
- float nabla = tex_input_value(in[1], p, thread);
- float val;
- float nor[3];
+ float nabla = tex_input_value(in[1], p, thread);
+ float val;
+ float nor[3];
- TexParams np = *p;
- np.co = new_co;
+ TexParams np = *p;
+ np.co = new_co;
- val = tex_input_value(in[0], p, thread);
+ val = tex_input_value(in[0], p, thread);
- new_co[0] = co[0] + nabla;
- new_co[1] = co[1];
- new_co[2] = co[2];
- nor[0] = tex_input_value(in[0], &np, thread);
+ new_co[0] = co[0] + nabla;
+ new_co[1] = co[1];
+ new_co[2] = co[2];
+ nor[0] = tex_input_value(in[0], &np, thread);
- new_co[0] = co[0];
- new_co[1] = co[1] + nabla;
- nor[1] = tex_input_value(in[0], &np, thread);
+ new_co[0] = co[0];
+ new_co[1] = co[1] + nabla;
+ nor[1] = tex_input_value(in[0], &np, thread);
- new_co[1] = co[1];
- new_co[2] = co[2] + nabla;
- nor[2] = tex_input_value(in[0], &np, thread);
+ new_co[1] = co[1];
+ new_co[2] = co[2] + nabla;
+ nor[2] = tex_input_value(in[0], &np, thread);
- out[0] = val - nor[0];
- out[1] = val - nor[1];
- out[2] = val - nor[2];
+ out[0] = val - nor[0];
+ out[1] = val - nor[1];
+ out[2] = val - nor[2];
}
-static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &normalfn, data);
+ tex_output(node, execdata, in, out[0], &normalfn, data);
}
void register_node_type_tex_valtonor(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTOR, 0);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTOR, 0);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
index 9db1caf6a85..8c315faaf8a 100644
--- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c
@@ -21,84 +21,93 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
#include "IMB_colormanagement.h"
/* **************** VALTORGB ******************** */
static bNodeSocketTemplate valtorgb_in[] = {
- { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { -1, 0, "" },
+ {SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ {-1, 0, ""},
};
static bNodeSocketTemplate valtorgb_out[] = {
- { SOCK_RGBA, 0, N_("Color")},
- { -1, 0, "" },
+ {SOCK_RGBA, 0, N_("Color")},
+ {-1, 0, ""},
};
static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread)
{
- if (node->storage) {
- float fac = tex_input_value(in[0], p, thread);
+ if (node->storage) {
+ float fac = tex_input_value(in[0], p, thread);
- BKE_colorband_evaluate(node->storage, fac, out);
- }
+ BKE_colorband_evaluate(node->storage, fac, out);
+ }
}
-static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void valtorgb_exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &valtorgb_colorfn, data);
+ tex_output(node, execdata, in, out[0], &valtorgb_colorfn, data);
}
static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node)
{
- node->storage = BKE_colorband_add(true);
+ node->storage = BKE_colorband_add(true);
}
void register_node_type_tex_valtorgb(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
- node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out);
- node_type_size_preset(&ntype, NODE_SIZE_LARGE);
- node_type_init(&ntype, valtorgb_init);
- node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
- node_type_exec(&ntype, NULL, NULL, valtorgb_exec);
+ tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, 0);
+ node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out);
+ node_type_size_preset(&ntype, NODE_SIZE_LARGE);
+ node_type_init(&ntype, valtorgb_init);
+ node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
+ node_type_exec(&ntype, NULL, NULL, valtorgb_exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
/* **************** RGBTOBW ******************** */
static bNodeSocketTemplate rgbtobw_in[] = {
- { SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate rgbtobw_out[] = {
- { SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" },
+ {SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
-
-static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
+static void rgbtobw_valuefn(
+ float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
- float cin[4];
- tex_input_rgba(cin, in[0], p, thread);
- *out = IMB_colormanagement_get_luminance(cin);
+ float cin[4];
+ tex_input_rgba(cin, in[0], p, thread);
+ *out = IMB_colormanagement_get_luminance(cin);
}
-static void rgbtobw_exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
+static void rgbtobw_exec(void *data,
+ int UNUSED(thread),
+ bNode *node,
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **out)
{
- tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, data);
+ tex_output(node, execdata, in, out[0], &rgbtobw_valuefn, data);
}
void register_node_type_tex_rgbtobw(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
- node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out);
- node_type_exec(&ntype, NULL, NULL, rgbtobw_exec);
+ tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
+ node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out);
+ node_type_exec(&ntype, NULL, NULL, rgbtobw_exec);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c
index f6adc256103..b0c119e975f 100644
--- a/source/blender/nodes/texture/nodes/node_texture_viewer.c
+++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c
@@ -21,43 +21,47 @@
* \ingroup texnodes
*/
-
#include "node_texture_util.h"
#include "NOD_texture.h"
#include <math.h>
static bNodeSocketTemplate inputs[] = {
- { SOCK_RGBA, 1, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f },
- { -1, 0, "" },
+ {SOCK_RGBA, 1, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f},
+ {-1, 0, ""},
};
static bNodeSocketTemplate outputs[] = {
- { -1, 0, "" },
+ {-1, 0, ""},
};
-static void exec(void *data, int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *execdata, bNodeStack **in, bNodeStack **UNUSED(out))
+static void exec(void *data,
+ int UNUSED(thread),
+ bNode *UNUSED(node),
+ bNodeExecData *execdata,
+ bNodeStack **in,
+ bNodeStack **UNUSED(out))
{
- TexCallData *cdata = (TexCallData *)data;
+ TexCallData *cdata = (TexCallData *)data;
- if (cdata->do_preview) {
- TexParams params;
- float col[4];
- params_from_cdata(&params, cdata);
+ if (cdata->do_preview) {
+ TexParams params;
+ float col[4];
+ params_from_cdata(&params, cdata);
- tex_input_rgba(col, in[0], &params, cdata->thread);
- tex_do_preview(execdata->preview, params.previewco, col, cdata->do_manage);
- }
+ tex_input_rgba(col, in[0], &params, cdata->thread);
+ tex_do_preview(execdata->preview, params.previewco, col, cdata->do_manage);
+ }
}
void register_node_type_tex_viewer(void)
{
- static bNodeType ntype;
+ static bNodeType ntype;
- tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW);
- node_type_socket_templates(&ntype, inputs, outputs);
- node_type_exec(&ntype, NULL, NULL, exec);
+ tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW);
+ node_type_socket_templates(&ntype, inputs, outputs);
+ node_type_exec(&ntype, NULL, NULL, exec);
- /* Do not allow muting viewer node. */
- node_type_internal_links(&ntype, NULL);
+ /* Do not allow muting viewer node. */
+ node_type_internal_links(&ntype, NULL);
- nodeRegisterType(&ntype);
+ nodeRegisterType(&ntype);
}