| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2018-06-01 18:19:39 +02:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2005 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup nodes | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_node_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "node_shader_util.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "node_exec.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-02 11:47:00 +02:00
										 |  |  | bool sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree) | 
					
						
							| 
									
										
										
										
											2013-03-18 16:34:57 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return STREQ(ntree->idname, "ShaderNodeTree"); | 
					
						
							| 
									
										
										
										
											2013-03-18 16:34:57 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | void sh_node_type_base( | 
					
						
							|  |  |  |     struct bNodeType *ntype, int type, const char *name, short nclass, short flag) | 
					
						
							| 
									
										
										
										
											2013-03-18 16:34:57 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   node_type_base(ntype, type, name, nclass, flag); | 
					
						
							| 
									
										
										
										
											2018-06-08 08:07:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   ntype->poll = sh_node_poll_default; | 
					
						
							|  |  |  |   ntype->insert_link = node_insert_link_default; | 
					
						
							|  |  |  |   ntype->update_internal_links = node_update_internal_links_default; | 
					
						
							| 
									
										
										
										
											2013-03-18 16:34:57 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | /* ****** */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   const float *from = ns->vec; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (type_in == SOCK_FLOAT) { | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     if (ns->sockettype == SOCK_FLOAT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       *in = *from; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       *in = (from[0] + from[1] + from[2]) / 3.0f; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   } | 
					
						
							|  |  |  |   else if (type_in == SOCK_VECTOR) { | 
					
						
							|  |  |  |     if (ns->sockettype == SOCK_FLOAT) { | 
					
						
							|  |  |  |       in[0] = from[0]; | 
					
						
							|  |  |  |       in[1] = from[0]; | 
					
						
							|  |  |  |       in[2] = from[0]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |       copy_v3_v3(in, from); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { /* type_in==SOCK_RGBA */ | 
					
						
							|  |  |  |     if (ns->sockettype == SOCK_RGBA) { | 
					
						
							|  |  |  |       copy_v4_v4(in, from); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else if (ns->sockettype == SOCK_FLOAT) { | 
					
						
							|  |  |  |       in[0] = from[0]; | 
					
						
							|  |  |  |       in[1] = from[0]; | 
					
						
							|  |  |  |       in[2] = from[0]; | 
					
						
							|  |  |  |       in[3] = 1.0f; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |       copy_v3_v3(in, from); | 
					
						
							|  |  |  |       in[3] = 1.0f; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   memset(gs, 0, sizeof(*gs)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (ns == NULL) { | 
					
						
							| 
									
										
										
										
											2019-04-29 20:12:09 +10:00
										 |  |  |     /* node_get_stack() will generate NULL bNodeStack pointers
 | 
					
						
							|  |  |  |      * for unknown/unsupported types of sockets. */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     zero_v4(gs->vec); | 
					
						
							|  |  |  |     gs->link = NULL; | 
					
						
							|  |  |  |     gs->type = GPU_NONE; | 
					
						
							|  |  |  |     gs->hasinput = false; | 
					
						
							|  |  |  |     gs->hasoutput = false; | 
					
						
							|  |  |  |     gs->sockettype = type; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     nodestack_get_vec(gs->vec, type, ns); | 
					
						
							|  |  |  |     gs->link = ns->data; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     if (type == SOCK_FLOAT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       gs->type = GPU_FLOAT; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |     else if (type == SOCK_INT) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       gs->type = GPU_FLOAT; /* HACK: Support as float. */ | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |     else if (type == SOCK_VECTOR) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       gs->type = GPU_VEC3; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |     else if (type == SOCK_RGBA) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       gs->type = GPU_VEC4; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |     else if (type == SOCK_SHADER) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       gs->type = GPU_CLOSURE; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       gs->type = GPU_NONE; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     gs->hasinput = ns->hasinput && ns->data; | 
					
						
							|  |  |  |     /* XXX Commented out the ns->data check here, as it seems it's not always set,
 | 
					
						
							|  |  |  |      *     even though there *is* a valid connection/output... But that might need | 
					
						
							|  |  |  |      *     further investigation. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     gs->hasoutput = ns->hasoutput /*&& ns->data*/; | 
					
						
							|  |  |  |     gs->sockettype = ns->sockettype; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void node_data_from_gpu_stack(bNodeStack *ns, GPUNodeStack *gs) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   copy_v4_v4(ns->vec, gs->vec); | 
					
						
							|  |  |  |   ns->data = gs->link; | 
					
						
							|  |  |  |   ns->sockettype = gs->sockettype; | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeStack **ns) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   bNodeSocket *sock; | 
					
						
							|  |  |  |   int i; | 
					
						
							| 
									
										
										
										
											2018-06-08 08:07:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     node_gpu_stack_from_data(&gs[i], sock->type, ns[i]); | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-06-08 08:07:48 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   gs[i].end = true; | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNodeStack *gs) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   bNodeSocket *sock; | 
					
						
							|  |  |  |   int i; | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     node_data_from_gpu_stack(ns[i], &gs[i]); | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-08 13:07:16 +00:00
										 |  |  | bNode *nodeGetActiveTexture(bNodeTree *ntree) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   /* this is the node we texture paint and draw in textured draw */ | 
					
						
							|  |  |  |   bNode *node, *tnode, *inactivenode = NULL, *activetexnode = NULL, *activegroup = NULL; | 
					
						
							|  |  |  |   bool hasgroup = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   if (!ntree) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   for (node = ntree->nodes.first; node; node = node->next) { | 
					
						
							|  |  |  |     if (node->flag & NODE_ACTIVE_TEXTURE) { | 
					
						
							|  |  |  |       activetexnode = node; | 
					
						
							|  |  |  |       /* if active we can return immediately */ | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       if (node->flag & NODE_ACTIVE) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         return node; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       inactivenode = node; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     else if (node->type == NODE_GROUP) { | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       if (node->flag & NODE_ACTIVE) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         activegroup = node; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       } | 
					
						
							|  |  |  |       else { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         hasgroup = true; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* first, check active group for textures */ | 
					
						
							|  |  |  |   if (activegroup) { | 
					
						
							|  |  |  |     tnode = nodeGetActiveTexture((bNodeTree *)activegroup->id); | 
					
						
							|  |  |  |     /* active node takes priority, so ignore any other possible nodes here */ | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     if (tnode) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       return tnode; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   if (activetexnode) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return activetexnode; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (hasgroup) { | 
					
						
							|  |  |  |     /* node active texture node in this tree, look inside groups */ | 
					
						
							|  |  |  |     for (node = ntree->nodes.first; node; node = node->next) { | 
					
						
							|  |  |  |       if (node->type == NODE_GROUP) { | 
					
						
							|  |  |  |         tnode = nodeGetActiveTexture((bNodeTree *)node->id); | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |         if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           return tnode; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return inactivenode; | 
					
						
							| 
									
										
										
										
											2011-11-08 13:07:16 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-02 16:37:54 +02:00
										 |  |  | void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node) | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   bNodeExec *nodeexec; | 
					
						
							|  |  |  |   bNode *node; | 
					
						
							|  |  |  |   int n; | 
					
						
							|  |  |  |   bNodeStack *stack; | 
					
						
							|  |  |  |   bNodeStack *nsin[MAX_SOCKET];  /* arbitrary... watch this */ | 
					
						
							|  |  |  |   bNodeStack *nsout[MAX_SOCKET]; /* arbitrary... watch this */ | 
					
						
							|  |  |  |   GPUNodeStack gpuin[MAX_SOCKET + 1], gpuout[MAX_SOCKET + 1]; | 
					
						
							|  |  |  |   bool do_it; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   stack = exec->stack; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) { | 
					
						
							|  |  |  |     node = nodeexec->node; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     do_it = false; | 
					
						
							|  |  |  |     /* for groups, only execute outputs for edited group */ | 
					
						
							|  |  |  |     if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) { | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       if ((output_node != NULL) && (node == output_node)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |         do_it = true; | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							|  |  |  |       do_it = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (do_it) { | 
					
						
							|  |  |  |       if (node->typeinfo->gpufunc) { | 
					
						
							|  |  |  |         node_get_stack(node, stack, nsin, nsout); | 
					
						
							|  |  |  |         gpu_stack_from_data_list(gpuin, &node->inputs, nsin); | 
					
						
							|  |  |  |         gpu_stack_from_data_list(gpuout, &node->outputs, nsout); | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |         if (node->typeinfo->gpufunc(mat, node, &nodeexec->data, gpuin, gpuout)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |           data_from_gpu_stack_list(&node->outputs, nsout, gpuout); | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-09-05 21:01:50 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-11-08 11:38:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | void node_shader_gpu_tex_mapping(GPUMaterial *mat, | 
					
						
							|  |  |  |                                  bNode *node, | 
					
						
							|  |  |  |                                  GPUNodeStack *in, | 
					
						
							|  |  |  |                                  GPUNodeStack *UNUSED(out)) | 
					
						
							| 
									
										
										
										
											2011-11-08 11:38:16 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   NodeTexBase *base = node->storage; | 
					
						
							|  |  |  |   TexMapping *texmap = &base->tex_mapping; | 
					
						
							|  |  |  |   float domin = (texmap->flag & TEXMAP_CLIP_MIN) != 0; | 
					
						
							|  |  |  |   float domax = (texmap->flag & TEXMAP_CLIP_MAX) != 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) { | 
					
						
							|  |  |  |     static float max[3] = {FLT_MAX, FLT_MAX, FLT_MAX}; | 
					
						
							|  |  |  |     static float min[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; | 
					
						
							|  |  |  |     GPUNodeLink *tmin, *tmax, *tmat0, *tmat1, *tmat2, *tmat3; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tmin = GPU_uniform((domin) ? texmap->min : min); | 
					
						
							|  |  |  |     tmax = GPU_uniform((domax) ? texmap->max : max); | 
					
						
							|  |  |  |     tmat0 = GPU_uniform((float *)texmap->mat[0]); | 
					
						
							|  |  |  |     tmat1 = GPU_uniform((float *)texmap->mat[1]); | 
					
						
							|  |  |  |     tmat2 = GPU_uniform((float *)texmap->mat[2]); | 
					
						
							|  |  |  |     tmat3 = GPU_uniform((float *)texmap->mat[3]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-04 23:17:13 +02:00
										 |  |  |     GPU_link(mat, "mapping_mat4", in[0].link, tmat0, tmat1, tmat2, tmat3, tmin, tmax, &in[0].link); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     if (texmap->type == TEXMAP_TYPE_NORMAL) { | 
					
						
							| 
									
										
										
											
												GPU: Split gpu_shader_material into multiple files.
This patch continue the efforts to split the `gpu_shader_material` file
started in D5569.
Dependency resolution is now recursive. Each shading node gets its own
file. Additionally, some utility files are added to be shared between
files, like `math_util`, `color_util`, and `hash`. Some files are always
included because they may be used in the execution function, like
`world_normals`.
Some glsl functions appeared to be unused, so they were removed, like
`output_node`, `bits_to_01`, and `exp_blender`. Other functions have
been renamed to be more general and get used as utils, like `texco_norm`
which became `vector_normalize`.
A lot of the opengl tests fails, but those same tests also fail in
master, so this is probably unrelated to this patch.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5616
											
										 
											2019-08-30 17:23:04 +02:00
										 |  |  |       GPU_link(mat, "vector_normalize", in[0].link, &in[0].link); | 
					
						
							| 
									
										
										
										
											2019-04-22 13:31:31 +10:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-11-08 11:38:16 +00:00
										 |  |  | } |