Commit: a4f173b0f94a01405ba7497dcd6a7bc59ed3afe3
Author: Omar Emara
Date:   Fri Apr 1 13:12:02 2022 +0200
Branches: temp-viewport-compositor-compiler
https://developer.blender.org/rBa4f173b0f94a01405ba7497dcd6a7bc59ed3afe3

Viewport Compositor: Implement Separate/Combine XYZ

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

M       
source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_separate_combine.glsl
M       source/blender/nodes/composite/nodes/node_composite_sepcomb_xyz.cc

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

diff --git 
a/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_separate_combine.glsl
 
b/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_separate_combine.glsl
index 5a14adf841b..c1e3477dac1 100644
--- 
a/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_separate_combine.glsl
+++ 
b/source/blender/gpu/shaders/compositor/material/gpu_shader_compositor_separate_combine.glsl
@@ -1,3 +1,17 @@
+/* ** Combine/Separate XYZ ** */
+
+void node_composite_combine_xyz(float x, float y, float z, out vec3 vector)
+{
+  vector = vec3(x, y, z);
+}
+
+void node_composite_separate_xyz(vec3 vector, out float x, out float y, out 
float z)
+{
+  x = vector.x;
+  y = vector.y;
+  z = vector.z;
+}
+
 /* ** Combine/Separate RGBA ** */
 
 void node_composite_combine_rgba(float r, float g, float b, float a, out vec4 
color)
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_xyz.cc 
b/source/blender/nodes/composite/nodes/node_composite_sepcomb_xyz.cc
index 5dfcf5dca1e..7748ec89136 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_xyz.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_xyz.cc
@@ -21,10 +21,15 @@
  * \ingroup cmpnodes
  */
 
+#include "GPU_material.h"
+
+#include "NOD_compositor_execute.hh"
+
 #include "node_composite_util.hh"
 
 /* **************** SEPARATE XYZ ******************** */
-namespace blender::nodes {
+
+namespace blender::nodes::node_composite_separate_xyz_cc {
 
 static void cmp_node_separate_xyz_declare(NodeDeclarationBuilder &b)
 {
@@ -34,21 +39,44 @@ static void 
cmp_node_separate_xyz_declare(NodeDeclarationBuilder &b)
   b.add_output<decl::Float>("Z");
 }
 
-}  // namespace blender::nodes
+using namespace blender::viewport_compositor;
+
+class SeparateXYZGPUMaterialNode : public GPUMaterialNode {
+ public:
+  using GPUMaterialNode::GPUMaterialNode;
+
+  void compile(GPUMaterial *material) override
+  {
+    GPUNodeStack *inputs = get_inputs_array();
+    GPUNodeStack *outputs = get_outputs_array();
+
+    GPU_stack_link(material, &node(), "node_composite_separate_xyz", inputs, 
outputs);
+  }
+};
+
+static GPUMaterialNode *get_compositor_gpu_material_node(DNode node)
+{
+  return new SeparateXYZGPUMaterialNode(node);
+}
+
+}  // namespace blender::nodes::node_composite_separate_xyz_cc
 
 void register_node_type_cmp_separate_xyz()
 {
+  namespace file_ns = blender::nodes::node_composite_separate_xyz_cc;
+
   static bNodeType ntype;
 
   cmp_node_type_base(&ntype, CMP_NODE_SEPARATE_XYZ, "Separate XYZ", 
NODE_CLASS_CONVERTER);
-  ntype.declare = blender::nodes::cmp_node_separate_xyz_declare;
+  ntype.declare = file_ns::cmp_node_separate_xyz_declare;
+  ntype.get_compositor_gpu_material_node = 
file_ns::get_compositor_gpu_material_node;
 
   nodeRegisterType(&ntype);
 }
 
 /* **************** COMBINE XYZ ******************** */
 
-namespace blender::nodes {
+namespace blender::nodes::node_composite_combine_xyz_cc {
 
 static void cmp_node_combine_xyz_declare(NodeDeclarationBuilder &b)
 {
@@ -58,14 +86,37 @@ static void 
cmp_node_combine_xyz_declare(NodeDeclarationBuilder &b)
   b.add_output<decl::Vector>("Vector");
 }
 
-}  // namespace blender::nodes
+using namespace blender::viewport_compositor;
+
+class CombineXYZGPUMaterialNode : public GPUMaterialNode {
+ public:
+  using GPUMaterialNode::GPUMaterialNode;
+
+  void compile(GPUMaterial *material) override
+  {
+    GPUNodeStack *inputs = get_inputs_array();
+    GPUNodeStack *outputs = get_outputs_array();
+
+    GPU_stack_link(material, &node(), "node_composite_combine_xyz", inputs, 
outputs);
+  }
+};
+
+static GPUMaterialNode *get_compositor_gpu_material_node(DNode node)
+{
+  return new CombineXYZGPUMaterialNode(node);
+}
+
+}  // namespace blender::nodes::node_composite_combine_xyz_cc
 
 void register_node_type_cmp_combine_xyz()
 {
+  namespace file_ns = blender::nodes::node_composite_combine_xyz_cc;
+
   static bNodeType ntype;
 
   cmp_node_type_base(&ntype, CMP_NODE_COMBINE_XYZ, "Combine XYZ", 
NODE_CLASS_CONVERTER);
-  ntype.declare = blender::nodes::cmp_node_combine_xyz_declare;
+  ntype.declare = file_ns::cmp_node_combine_xyz_declare;
+  ntype.get_compositor_gpu_material_node = 
file_ns::get_compositor_gpu_material_node;
 
   nodeRegisterType(&ntype);
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to