[Bf-blender-cvs] [8d080013f56] master: Fix T100285: Shader value node always outputs zero

Omar Emara noreply at git.blender.org
Mon Aug 8 17:32:15 CEST 2022


Commit: 8d080013f561f0084d8d937c9855c41be63170a4
Author: Omar Emara
Date:   Mon Aug 8 17:31:25 2022 +0200
Branches: master
https://developer.blender.org/rB8d080013f561f0084d8d937c9855c41be63170a4

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

===================================================================

M	source/blender/gpu/GPU_material.h
M	source/blender/gpu/intern/gpu_node_graph.c
M	source/blender/nodes/shader/nodes/node_shader_rgb.cc
M	source/blender/nodes/shader/nodes/node_shader_value.cc

===================================================================

diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 12a7cf49f9d..1ab06f3369d 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index c7b2fde492f..377cbc53893 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -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)
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)



More information about the Bf-blender-cvs mailing list