From d3758892987d76749fdf1211ed27ff77f39b5b3b Mon Sep 17 00:00:00 2001 From: Charlie Jolly Date: Tue, 23 Mar 2021 09:21:56 +0000 Subject: Nodes: Add Refract and Faceforward functions to Vector Maths nodes Cycles, Eevee, OSL, Geo, Attribute Based on outdated refract patch D6619 by @cubic_sloth `refract` and `faceforward` are standard functions in GLSL, OSL and Godot shader languages. Adding these functions provides Blender shader artists access to these standard functions. Reviewed By: brecht Differential Revision: https://developer.blender.org/D10622 --- source/blender/nodes/intern/math_functions.cc | 4 ++++ source/blender/nodes/intern/node_util.c | 19 ++++++++++--------- source/blender/nodes/intern/node_util.h | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'source/blender/nodes/intern') diff --git a/source/blender/nodes/intern/math_functions.cc b/source/blender/nodes/intern/math_functions.cc index 14de2fce9b3..fb34144abf6 100644 --- a/source/blender/nodes/intern/math_functions.cc +++ b/source/blender/nodes/intern/math_functions.cc @@ -205,6 +205,10 @@ const FloatMathOperationInfo *get_float3_math_operation_info(const int operation RETURN_OPERATION_INFO("Cosine", "vector_math_cosine"); case NODE_VECTOR_MATH_TANGENT: RETURN_OPERATION_INFO("Tangent", "vector_math_tangent"); + case NODE_VECTOR_MATH_REFRACT: + RETURN_OPERATION_INFO("Refract", "vector_math_refract"); + case NODE_VECTOR_MATH_FACEFORWARD: + RETURN_OPERATION_INFO("Faceforward", "vector_math_faceforward"); } #undef RETURN_OPERATION_INFO diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index c7c3ced4e56..00db819721c 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -90,6 +90,13 @@ void node_sock_label(bNodeSocket *sock, const char *name) BLI_strncpy(sock->label, name, MAX_NAME); } +void node_sock_label_clear(bNodeSocket *sock) +{ + if (sock->label[0] != '\0') { + sock->label[0] = '\0'; + } +} + void node_math_update(bNodeTree *UNUSED(ntree), bNode *node) { bNodeSocket *sock1 = BLI_findlink(&node->inputs, 0); @@ -127,15 +134,9 @@ void node_math_update(bNodeTree *UNUSED(ntree), bNode *node) NODE_MATH_SMOOTH_MIN, NODE_MATH_SMOOTH_MAX)); - if (sock1->label[0] != '\0') { - sock1->label[0] = '\0'; - } - if (sock2->label[0] != '\0') { - sock2->label[0] = '\0'; - } - if (sock3->label[0] != '\0') { - sock3->label[0] = '\0'; - } + node_sock_label_clear(sock1); + node_sock_label_clear(sock2); + node_sock_label_clear(sock3); switch (node->custom1) { case NODE_MATH_WRAP: diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 1b542a9420a..9cbb21e02f7 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -71,6 +71,7 @@ extern void *node_initexec_curves(struct bNodeExecContext *context, /**** Updates ****/ void node_sock_label(struct bNodeSocket *sock, const char *name); +void node_sock_label_clear(struct bNodeSocket *sock); void node_math_update(struct bNodeTree *ntree, struct bNode *node); /**** Labels ****/ -- cgit v1.2.3