Fix T59501: Eevee doesn't use integer node sockets
This is a hacky fix. We just convert the int as a float and use it as such. This works ok for small int but will not be correct for numbers greater than 4194303. Correct support would require deeper change for UBO creation and socket conversion.
This commit is contained in:
@@ -1394,6 +1394,8 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
|
||||
static const char *gpu_uniform_set_function_from_type(eNodeSocketDatatype type)
|
||||
{
|
||||
switch (type) {
|
||||
/* For now INT is supported as float. */
|
||||
case SOCK_INT:
|
||||
case SOCK_FLOAT:
|
||||
return "set_value";
|
||||
case SOCK_VECTOR:
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
/* supported socket types in old nodes */
|
||||
int node_exec_socket_use_stack(bNodeSocket *sock)
|
||||
{
|
||||
return ELEM(sock->type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_SHADER);
|
||||
/* NOTE: INT supported as FLOAT. Only for EEVEE. */
|
||||
return ELEM(sock->type, SOCK_INT, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA, SOCK_SHADER);
|
||||
}
|
||||
|
||||
/* for a given socket, find the actual stack entry */
|
||||
|
||||
@@ -448,6 +448,7 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
|
||||
bNodeSocketValueVector *src_vector;
|
||||
bNodeSocketValueRGBA *src_rgba, *dst_rgba;
|
||||
bNodeSocketValueFloat *src_float, *dst_float;
|
||||
bNodeSocketValueInt *src_int;
|
||||
bool link_added = false;
|
||||
|
||||
for (group_node = localtree->nodes.first; group_node; group_node = group_node->next) {
|
||||
@@ -485,6 +486,15 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
|
||||
dst_rgba = value_socket->default_value;
|
||||
copy_v4_v4(dst_rgba->value, src_rgba->value);
|
||||
break;
|
||||
case SOCK_INT:
|
||||
/* HACK: Support as float. */
|
||||
value_node = nodeAddStaticNode(NULL, localtree, SH_NODE_VALUE);
|
||||
value_socket = ntree_shader_node_find_output(value_node, "Value");
|
||||
BLI_assert(value_socket != NULL);
|
||||
src_int = group_socket->default_value;
|
||||
dst_float = value_socket->default_value;
|
||||
dst_float->value = (float)(src_int->value);
|
||||
break;
|
||||
case SOCK_FLOAT:
|
||||
value_node = nodeAddStaticNode(NULL, localtree, SH_NODE_VALUE);
|
||||
value_socket = ntree_shader_node_find_output(value_node, "Value");
|
||||
|
||||
@@ -102,6 +102,8 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
|
||||
|
||||
if (type == SOCK_FLOAT)
|
||||
gs->type = GPU_FLOAT;
|
||||
else if (type == SOCK_INT)
|
||||
gs->type = GPU_FLOAT; /* HACK: Support as float. */
|
||||
else if (type == SOCK_VECTOR)
|
||||
gs->type = GPU_VEC3;
|
||||
else if (type == SOCK_RGBA)
|
||||
|
||||
Reference in New Issue
Block a user