Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Emara <mail@OmarEmara.dev>2022-08-08 18:31:25 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-08-08 18:31:25 +0300
commit8d080013f561f0084d8d937c9855c41be63170a4 (patch)
tree08a583256ece7ddf7d4be410b7549d66a2d3f207 /source/blender/nodes/shader
parentbca20c10da4f3bb92973913c953e4d58da9bd3f1 (diff)
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 b639e6086445f20d428df1f471c73922bbd54b67. 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
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb.cc5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.cc5
2 files changed, 6 insertions, 4 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_rgb.cc
index 38acfab322f..c854bc733a3 100644
--- a/source/blender/nodes/shader/nodes/node_shader_rgb.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb.cc
@@ -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
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc
index 362cdf58052..b6b7fe10cf9 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_value.cc
@@ -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)