EEVEE: Support different dimensions vector sockets

This patch adds support for the dimensions property of vector sockets,
support 2D and 4D sockets in addition to the currently supported 3D one.
This just involves assigning the correct GPU type when constructing the
GPU materials from nodes.

The only node that uses 2D sockets for now is the Radial Tilling node,
so we just need to update its interface.

Pull Request: https://projects.blender.org/blender/blender/pulls/148034
This commit is contained in:
Omar Emara
2025-10-14 13:24:17 +02:00
committed by Omar Emara
parent bf09f90338
commit df8683ec2a
4 changed files with 25 additions and 14 deletions

View File

@@ -15,7 +15,7 @@
/* Undefine macro flags used for code adaption. */
/* No macro flags necessary, as code is adapted to GLSL by default. */
void node_radial_tiling(float3 coord,
void node_radial_tiling(float2 coord,
float r_gon_sides,
float r_gon_roundness,
float normalize_r_gon_parameter,

View File

@@ -169,7 +169,7 @@ static void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
}
}
void node_gpu_stack_from_data(GPUNodeStack *gs, int type, bNodeStack *ns)
void node_gpu_stack_from_data(GPUNodeStack *gs, bNodeSocket *socket, bNodeStack *ns)
{
memset(gs, 0, sizeof(*gs));
@@ -181,28 +181,39 @@ void node_gpu_stack_from_data(GPUNodeStack *gs, int type, bNodeStack *ns)
gs->type = GPU_NONE;
gs->hasinput = false;
gs->hasoutput = false;
gs->sockettype = type;
gs->sockettype = socket->type;
}
else {
nodestack_get_vec(gs->vec, type, ns);
nodestack_get_vec(gs->vec, socket->type, ns);
gs->link = (GPUNodeLink *)ns->data;
if (type == SOCK_FLOAT) {
if (socket->type == SOCK_FLOAT) {
gs->type = GPU_FLOAT;
}
else if (type == SOCK_INT) {
else if (socket->type == SOCK_INT) {
gs->type = GPU_FLOAT; /* HACK: Support as float. */
}
else if (type == SOCK_BOOLEAN) {
else if (socket->type == SOCK_BOOLEAN) {
gs->type = GPU_FLOAT; /* HACK: Support as float. */
}
else if (type == SOCK_VECTOR) {
gs->type = GPU_VEC3;
else if (socket->type == SOCK_VECTOR) {
switch (socket->default_value_typed<bNodeSocketValueVector>()->dimensions) {
case 2:
gs->type = GPU_VEC2;
break;
case 3:
default:
gs->type = GPU_VEC3;
break;
case 4:
gs->type = GPU_VEC4;
break;
}
}
else if (type == SOCK_RGBA) {
else if (socket->type == SOCK_RGBA) {
gs->type = GPU_VEC4;
}
else if (type == SOCK_SHADER) {
else if (socket->type == SOCK_SHADER) {
gs->type = GPU_CLOSURE;
}
else {
@@ -230,7 +241,7 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
{
int i;
LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, sockets, i) {
node_gpu_stack_from_data(&gs[i], socket->type, ns[i]);
node_gpu_stack_from_data(&gs[i], socket, ns[i]);
}
gs[i].end = true;

View File

@@ -65,7 +65,7 @@ struct XYZ_to_RGB /* Transposed #imbuf_xyz_to_rgb, passed as 3x vec3. */
float r[3], g[3], b[3];
};
void node_gpu_stack_from_data(GPUNodeStack *gs, int type, bNodeStack *ns);
void node_gpu_stack_from_data(GPUNodeStack *gs, bNodeSocket *socket, bNodeStack *ns);
void node_data_from_gpu_stack(bNodeStack *ns, GPUNodeStack *gs);
void node_shader_gpu_bump_tex_coord(GPUMaterial *mat, bNode *node, GPUNodeLink **link);
void node_shader_gpu_default_tex_coord(GPUMaterial *mat, bNode *node, GPUNodeLink **link);

View File

@@ -56,7 +56,7 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack *
bNodeStack *ns = node_get_socket_stack(gstack, sock);
if (ns) {
/* convert the node stack data result back to gpu stack */
node_gpu_stack_from_data(&out[a], sock->type, ns);
node_gpu_stack_from_data(&out[a], sock, ns);
}
}
}