Fix T100285: Shader value node always outputs zero

The shader value node always outputs zero in some cases even when its
value is not zero.

This is caused by b639e60864. In that
commit, the behavior of GPU node linking changed such that unlinked
sockets get their value from their associated GPU node stack instead of
the socket itself. But execution node stacks do not always have their
output values initialized, and since the value node stores its value in
its output, it follows that its uniform value will be wrong.

This patch fixes that by getting the value directly from the socket.
This is also done fro the RGBA node, since it is implemented similarly.
Finally, the GPU_uniformbuf_link_out function was removed since it is no
longer used and does not make sense anymore.

Differential Revision: https://developer.blender.org/D15641

Reviewed By: Clement
This commit is contained in:
Omar Emara 2022-08-08 17:31:25 +02:00
parent bca20c10da
commit 8d080013f5
Notes: blender-bot 2023-09-08 04:55:43 +02:00
Referenced by issue #100285, Regression: EEVEE: Mix Shader node always receives 0.0 value from Value node
4 changed files with 6 additions and 16 deletions

View File

@ -167,10 +167,6 @@ bool GPU_stack_link(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out,
...);
GPUNodeLink *GPU_uniformbuf_link_out(struct GPUMaterial *mat,
struct bNode *node,
struct GPUNodeStack *stack,
int index);
void GPU_material_output_surface(GPUMaterial *material, GPUNodeLink *link);
void GPU_material_output_volume(GPUMaterial *material, GPUNodeLink *link);

View File

@ -738,14 +738,6 @@ bool GPU_stack_link(GPUMaterial *material,
return valid;
}
GPUNodeLink *GPU_uniformbuf_link_out(GPUMaterial *mat,
bNode *node,
GPUNodeStack *stack,
const int index)
{
return gpu_uniformbuffer_link(mat, node, stack, index, SOCK_OUT);
}
/* Node Graph */
static void gpu_inputs_free(ListBase *inputs)

View File

@ -20,8 +20,9 @@ static int gpu_shader_rgb(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
GPUNodeLink *link = GPU_uniformbuf_link_out(mat, node, out, 0);
return GPU_stack_link(mat, node, "set_rgba", in, out, link);
const bNodeSocket *socket = static_cast<bNodeSocket *>(node->outputs.first);
float *value = static_cast<bNodeSocketValueRGBA *>(socket->default_value)->value;
return GPU_link(mat, "set_rgba", GPU_uniform(value), &out->link);
}
} // namespace blender::nodes::node_shader_rgb_cc

View File

@ -20,8 +20,9 @@ static int gpu_shader_value(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
GPUNodeLink *link = GPU_uniformbuf_link_out(mat, node, out, 0);
return GPU_stack_link(mat, node, "set_value", in, out, link);
const bNodeSocket *socket = static_cast<bNodeSocket *>(node->outputs.first);
float value = static_cast<bNodeSocketValueFloat *>(socket->default_value)->value;
return GPU_link(mat, "set_value", GPU_uniform(&value), &out->link);
}
static void sh_node_value_build_multi_function(NodeMultiFunctionBuilder &builder)