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:
authorCharlie Jolly <charlie>2020-02-15 00:46:10 +0300
committerCharlie Jolly <mistajolly@gmail.com>2020-02-15 01:14:05 +0300
commit635ab9d1dded4d4975bd4486718fde19e8e901ca (patch)
tree63ae9c050c4749212c2beed2e0e46d9bc14b6c72 /source/blender/nodes
parent44d7706fe1868d66e8e724aebd9c3841cca67794 (diff)
Shading: Extend Vector Math Node with Sin, Cos, Tan and Wrap functions
This adds some extra functions recently added to the float Maths Node. Not all functions have been ported over in this patch. Also: + Tidy up menu + Change node color to match other vector nodes, this helps distinguish vector and float nodes in the tree + Move shared OSL functions to new header node_math.h Reviewed By: brecht Differential Revision: https://developer.blender.org/D6713
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vector_math.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.c b/source/blender/nodes/shader/nodes/node_shader_vector_math.c
index ba53cfd1799..46a1779de08 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vector_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.c
@@ -27,6 +27,7 @@
static bNodeSocketTemplate sh_node_vector_math_in[] = {
{SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
+ {SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{SOCK_FLOAT, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
{-1, 0, ""}};
@@ -63,6 +64,10 @@ static int gpu_shader_vector_math(GPUMaterial *mat,
[NODE_VECTOR_MATH_ABSOLUTE] = "vector_math_absolute",
[NODE_VECTOR_MATH_MINIMUM] = "vector_math_minimum",
[NODE_VECTOR_MATH_MAXIMUM] = "vector_math_maximum",
+ [NODE_VECTOR_MATH_WRAP] = "vector_math_wrap",
+ [NODE_VECTOR_MATH_SINE] = "vector_math_sine",
+ [NODE_VECTOR_MATH_COSINE] = "vector_math_cosine",
+ [NODE_VECTOR_MATH_TANGENT] = "vector_math_tangent",
};
if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) {
@@ -76,6 +81,7 @@ static int gpu_shader_vector_math(GPUMaterial *mat,
static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node)
{
bNodeSocket *sockB = BLI_findlink(&node->inputs, 1);
+ bNodeSocket *sockC = BLI_findlink(&node->inputs, 2);
bNodeSocket *sockScale = nodeFindSocket(node, SOCK_IN, "Scale");
bNodeSocket *sockVector = nodeFindSocket(node, SOCK_OUT, "Vector");
@@ -83,6 +89,9 @@ static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node
nodeSetSocketAvailability(sockB,
!ELEM(node->custom1,
+ NODE_VECTOR_MATH_SINE,
+ NODE_VECTOR_MATH_COSINE,
+ NODE_VECTOR_MATH_TANGENT,
NODE_VECTOR_MATH_CEIL,
NODE_VECTOR_MATH_SCALE,
NODE_VECTOR_MATH_FLOOR,
@@ -90,6 +99,7 @@ static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node
NODE_VECTOR_MATH_ABSOLUTE,
NODE_VECTOR_MATH_FRACTION,
NODE_VECTOR_MATH_NORMALIZE));
+ nodeSetSocketAvailability(sockC, ELEM(node->custom1, NODE_VECTOR_MATH_WRAP));
nodeSetSocketAvailability(sockScale, node->custom1 == NODE_VECTOR_MATH_SCALE);
nodeSetSocketAvailability(sockVector,
!ELEM(node->custom1,
@@ -101,13 +111,30 @@ static void node_shader_update_vector_math(bNodeTree *UNUSED(ntree), bNode *node
NODE_VECTOR_MATH_LENGTH,
NODE_VECTOR_MATH_DISTANCE,
NODE_VECTOR_MATH_DOT_PRODUCT));
+
+ /* Labels */
+ if (sockB->label[0] != '\0') {
+ sockB->label[0] = '\0';
+ }
+ if (sockC->label[0] != '\0') {
+ sockC->label[0] = '\0';
+ }
+ switch (node->custom1) {
+ case NODE_VECTOR_MATH_WRAP:
+ node_sock_label(sockB, "Max");
+ node_sock_label(sockC, "Min");
+ break;
+ case NODE_VECTOR_MATH_SNAP:
+ node_sock_label(sockB, "Increment");
+ break;
+ }
}
void register_node_type_sh_vect_math(void)
{
static bNodeType ntype;
- sh_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_CONVERTOR, 0);
+ sh_node_type_base(&ntype, SH_NODE_VECTOR_MATH, "Vector Math", NODE_CLASS_OP_VECTOR, 0);
node_type_socket_templates(&ntype, sh_node_vector_math_in, sh_node_vector_math_out);
node_type_label(&ntype, node_vector_math_label);
node_type_gpu(&ntype, gpu_shader_vector_math);