[Bf-blender-cvs] [6716baa1f7b] blender-v2.83-release: Fix T76476 EEVEE: Invalid Vector to Float conversion for nodegroups

Clément Foucault noreply at git.blender.org
Thu May 14 20:08:26 CEST 2020


Commit: 6716baa1f7b9674e133b1c946a25c80fa682a239
Author: Clément Foucault
Date:   Thu May 14 19:56:14 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB6716baa1f7b9674e133b1c946a25c80fa682a239

Fix T76476 EEVEE: Invalid Vector to Float conversion for nodegroups

The previous code only handled the RGBA socket case. For vectors, we simply
use the average of the 3 compoments. This is done using a temp Vector Math
node using the dot operation.

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

M	source/blender/nodes/shader/node_shader_tree.c

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

diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index d44cb8c7de1..179a92ec7bd 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -385,9 +385,21 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
           /* Fix the case where the socket is actually converting the data. (see T71374)
            * We only do the case of lossy conversion to float.*/
           if ((socket->type == SOCK_FLOAT) && (link->fromsock->type != link->tosock->type)) {
-            bNode *tmp = nodeAddStaticNode(NULL, localtree, SH_NODE_RGBTOBW);
-            nodeAddLink(localtree, link->fromnode, link->fromsock, tmp, tmp->inputs.first);
-            nodeAddLink(localtree, tmp, tmp->outputs.first, node, socket);
+            if (link->fromsock->type == SOCK_RGBA) {
+              bNode *tmp = nodeAddStaticNode(NULL, localtree, SH_NODE_RGBTOBW);
+              nodeAddLink(localtree, link->fromnode, link->fromsock, tmp, tmp->inputs.first);
+              nodeAddLink(localtree, tmp, tmp->outputs.first, node, socket);
+            }
+            else if (link->fromsock->type == SOCK_VECTOR) {
+              bNode *tmp = nodeAddStaticNode(NULL, localtree, SH_NODE_VECTOR_MATH);
+              tmp->custom1 = NODE_VECTOR_MATH_DOT_PRODUCT;
+              bNodeSocket *dot_input1 = tmp->inputs.first;
+              bNodeSocket *dot_input2 = dot_input1->next;
+              bNodeSocketValueVector *input2_socket_value = dot_input2->default_value;
+              copy_v3_fl(input2_socket_value->value, 1.0f / 3.0f);
+              nodeAddLink(localtree, link->fromnode, link->fromsock, tmp, dot_input1);
+              nodeAddLink(localtree, tmp, tmp->outputs.last, node, socket);
+            }
           }
           continue;
         }



More information about the Bf-blender-cvs mailing list