Compositor: Combine and Separate XYZ Node
We have this node for shader and geometry nodes. Compositor can also work with vectors, and this can help with that. Reviewed By: manzanilla Maniphest Tasks: T95385 Differential Revision: https://developer.blender.org/D12919
This commit is contained in:
@@ -547,6 +547,8 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeCombYUVA"),
|
||||
NodeItem("CompositorNodeSepYCCA"),
|
||||
NodeItem("CompositorNodeCombYCCA"),
|
||||
NodeItem("CompositorNodeSeparateXYZ"),
|
||||
NodeItem("CompositorNodeCombineXYZ"),
|
||||
NodeItem("CompositorNodeSwitchView"),
|
||||
NodeItem("CompositorNodeConvertColorSpace"),
|
||||
]),
|
||||
|
||||
@@ -1291,6 +1291,8 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree *ntree, struct Scene *scene, i
|
||||
#define CMP_NODE_POSTERIZE 327
|
||||
#define CMP_NODE_CONVERT_COLOR_SPACE 328
|
||||
#define CMP_NODE_SCENE_TIME 329
|
||||
#define CMP_NODE_SEPARATE_XYZ 330
|
||||
#define CMP_NODE_COMBINE_XYZ 331
|
||||
|
||||
/* channel toggles */
|
||||
#define CMP_CHAN_RGB 1
|
||||
|
||||
@@ -4503,6 +4503,8 @@ static void registerCompositNodes()
|
||||
register_node_type_cmp_sepycca();
|
||||
register_node_type_cmp_combycca();
|
||||
register_node_type_cmp_premulkey();
|
||||
register_node_type_cmp_separate_xyz();
|
||||
register_node_type_cmp_combine_xyz();
|
||||
|
||||
register_node_type_cmp_diff_matte();
|
||||
register_node_type_cmp_distance_matte();
|
||||
|
||||
@@ -274,10 +274,14 @@ set(SRC
|
||||
# converter nodes
|
||||
nodes/COM_CombineColorNode.cc
|
||||
nodes/COM_CombineColorNode.h
|
||||
nodes/COM_CombineXYZNode.cc
|
||||
nodes/COM_CombineXYZNode.h
|
||||
nodes/COM_IDMaskNode.cc
|
||||
nodes/COM_IDMaskNode.h
|
||||
nodes/COM_SeparateColorNode.cc
|
||||
nodes/COM_SeparateColorNode.h
|
||||
nodes/COM_SeparateXYZNode.cc
|
||||
nodes/COM_SeparateXYZNode.h
|
||||
|
||||
nodes/COM_MapRangeNode.cc
|
||||
nodes/COM_MapRangeNode.h
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "COM_ColorSpillNode.h"
|
||||
#include "COM_ColorToBWNode.h"
|
||||
#include "COM_CombineColorNode.h"
|
||||
#include "COM_CombineXYZNode.h"
|
||||
#include "COM_CompositorNode.h"
|
||||
#include "COM_ConvertAlphaNode.h"
|
||||
#include "COM_ConvertColorSpaceNode.h"
|
||||
@@ -96,6 +97,7 @@
|
||||
#include "COM_ScaleOperation.h"
|
||||
#include "COM_SceneTimeNode.h"
|
||||
#include "COM_SeparateColorNode.h"
|
||||
#include "COM_SeparateXYZNode.h"
|
||||
#include "COM_SetAlphaNode.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
#include "COM_SplitViewerNode.h"
|
||||
@@ -434,6 +436,12 @@ Node *COM_convert_bnode(bNode *b_node)
|
||||
case CMP_NODE_CONVERT_COLOR_SPACE:
|
||||
node = new ConvertColorSpaceNode(b_node);
|
||||
break;
|
||||
case CMP_NODE_SEPARATE_XYZ:
|
||||
node = new SeparateXYZNode(b_node);
|
||||
break;
|
||||
case CMP_NODE_COMBINE_XYZ:
|
||||
node = new CombineXYZNode(b_node);
|
||||
break;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
55
source/blender/compositor/nodes/COM_CombineXYZNode.cc
Normal file
55
source/blender/compositor/nodes/COM_CombineXYZNode.cc
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Copyright 2021, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include "COM_CombineXYZNode.h"
|
||||
|
||||
#include "COM_ConvertOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
CombineXYZNode::CombineXYZNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
}
|
||||
|
||||
void CombineXYZNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &UNUSED(context)) const
|
||||
{
|
||||
NodeInput *input_x_socket = this->get_input_socket(0);
|
||||
NodeInput *input_y_socket = this->get_input_socket(1);
|
||||
NodeInput *input_z_socket = this->get_input_socket(2);
|
||||
NodeOutput *output_socket = this->get_output_socket(0);
|
||||
|
||||
CombineChannelsOperation *operation = new CombineChannelsOperation();
|
||||
if (input_x_socket->is_linked()) {
|
||||
operation->set_canvas_input_index(0);
|
||||
}
|
||||
else if (input_y_socket->is_linked()) {
|
||||
operation->set_canvas_input_index(1);
|
||||
}
|
||||
else {
|
||||
operation->set_canvas_input_index(2);
|
||||
}
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.map_input_socket(input_x_socket, operation->get_input_socket(0));
|
||||
converter.map_input_socket(input_y_socket, operation->get_input_socket(1));
|
||||
converter.map_input_socket(input_z_socket, operation->get_input_socket(2));
|
||||
converter.map_output_socket(output_socket, operation->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
36
source/blender/compositor/nodes/COM_CombineXYZNode.h
Normal file
36
source/blender/compositor/nodes/COM_CombineXYZNode.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Copyright 2021, Blender Foundation.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_Node.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
/**
|
||||
* \brief SeparateXYZNode
|
||||
* \ingroup Node
|
||||
*/
|
||||
class CombineXYZNode : public Node {
|
||||
public:
|
||||
CombineXYZNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
63
source/blender/compositor/nodes/COM_SeparateXYZNode.cc
Normal file
63
source/blender/compositor/nodes/COM_SeparateXYZNode.cc
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Copyright 2021, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include "COM_SeparateXYZNode.h"
|
||||
|
||||
#include "COM_ConvertOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
SeparateXYZNode::SeparateXYZNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void SeparateXYZNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &UNUSED(context)) const
|
||||
{
|
||||
NodeInput *vector_socket = this->get_input_socket(0);
|
||||
NodeOutput *output_x_socket = this->get_output_socket(0);
|
||||
NodeOutput *output_y_socket = this->get_output_socket(1);
|
||||
NodeOutput *output_z_socket = this->get_output_socket(2);
|
||||
|
||||
{
|
||||
SeparateChannelOperation *operation = new SeparateChannelOperation();
|
||||
operation->set_channel(0);
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(vector_socket, operation->get_input_socket(0));
|
||||
converter.map_output_socket(output_x_socket, operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
{
|
||||
SeparateChannelOperation *operation = new SeparateChannelOperation();
|
||||
operation->set_channel(1);
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(vector_socket, operation->get_input_socket(0));
|
||||
converter.map_output_socket(output_y_socket, operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
{
|
||||
SeparateChannelOperation *operation = new SeparateChannelOperation();
|
||||
operation->set_channel(2);
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(vector_socket, operation->get_input_socket(0));
|
||||
converter.map_output_socket(output_z_socket, operation->get_output_socket(0));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
36
source/blender/compositor/nodes/COM_SeparateXYZNode.h
Normal file
36
source/blender/compositor/nodes/COM_SeparateXYZNode.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Copyright 2021, Blender Foundation.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_Node.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
/**
|
||||
* \brief SeparateXYZNode
|
||||
* \ingroup Node
|
||||
*/
|
||||
class SeparateXYZNode : public Node {
|
||||
public:
|
||||
SeparateXYZNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
@@ -143,6 +143,7 @@ extern StructRNA RNA_CompositorNodeCombHSVA;
|
||||
extern StructRNA RNA_CompositorNodeCombRGBA;
|
||||
extern StructRNA RNA_CompositorNodeCombYCCA;
|
||||
extern StructRNA RNA_CompositorNodeCombYUVA;
|
||||
extern StructRNA RNA_CompositorNodeCombineXYZ;
|
||||
extern StructRNA RNA_CompositorNodeComposite;
|
||||
extern StructRNA RNA_CompositorNodeCornerPin;
|
||||
extern StructRNA RNA_CompositorNodeCrop;
|
||||
@@ -187,6 +188,7 @@ extern StructRNA RNA_CompositorNodeRLayers;
|
||||
extern StructRNA RNA_CompositorNodeRotate;
|
||||
extern StructRNA RNA_CompositorNodeScale;
|
||||
extern StructRNA RNA_CompositorNodeSceneTime;
|
||||
extern StructRNA RNA_CompositorNodeSeparateXYZ;
|
||||
extern StructRNA RNA_CompositorNodeSepHSVA;
|
||||
extern StructRNA RNA_CompositorNodeSepRGBA;
|
||||
extern StructRNA RNA_CompositorNodeSepYCCA;
|
||||
|
||||
@@ -140,6 +140,8 @@ void register_node_type_cmp_pixelate(void);
|
||||
void register_node_type_cmp_trackpos(void);
|
||||
void register_node_type_cmp_planetrackdeform(void);
|
||||
void register_node_type_cmp_cornerpin(void);
|
||||
void register_node_type_cmp_separate_xyz(void);
|
||||
void register_node_type_cmp_combine_xyz(void);
|
||||
|
||||
void node_cmp_rlayers_outputs(struct bNodeTree *ntree, struct bNode *node);
|
||||
void node_cmp_rlayers_register_pass(struct bNodeTree *ntree,
|
||||
|
||||
@@ -230,6 +230,8 @@ DefNode(CompositorNode, CMP_NODE_ANTIALIASING, def_cmp_antialiasing, "ANTIAL
|
||||
DefNode(CompositorNode, CMP_NODE_POSTERIZE, 0, "POSTERIZE", Posterize, "Posterize", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_CONVERT_COLOR_SPACE,def_cmp_convert_color_space, "CONVERT_COLORSPACE", ConvertColorSpace, "Color Space","" )
|
||||
DefNode(CompositorNode, CMP_NODE_SCENE_TIME, 0, "SCENE_TIME", SceneTime, "Scene Time", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_COMBINE_XYZ, 0, "COMBINE_XYZ", CombineXYZ, "Combine XYZ", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_SEPARATE_XYZ, 0, "SEPARATE_XYZ", SeparateXYZ, "Separate XYZ", "" )
|
||||
|
||||
DefNode(TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
|
||||
DefNode(TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
|
||||
|
||||
@@ -110,6 +110,7 @@ set(SRC
|
||||
nodes/node_composite_sepcomb_rgba.cc
|
||||
nodes/node_composite_sepcomb_ycca.cc
|
||||
nodes/node_composite_sepcomb_yuva.cc
|
||||
nodes/node_composite_sepcomb_xyz.cc
|
||||
nodes/node_composite_setalpha.cc
|
||||
nodes/node_composite_split_viewer.cc
|
||||
nodes/node_composite_stabilize2d.cc
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2021 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup cmpnodes
|
||||
*/
|
||||
|
||||
#include "node_composite_util.hh"
|
||||
|
||||
/* **************** SEPARATE XYZ ******************** */
|
||||
namespace blender::nodes {
|
||||
|
||||
static void cmp_node_separate_xyz_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Vector>("Vector").min(-10000.0f).max(10000.0f);
|
||||
b.add_output<decl::Float>("X");
|
||||
b.add_output<decl::Float>("Y");
|
||||
b.add_output<decl::Float>("Z");
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_cmp_separate_xyz()
|
||||
{
|
||||
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;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
||||
/* **************** COMBINE XYZ ******************** */
|
||||
|
||||
namespace blender::nodes {
|
||||
|
||||
static void cmp_node_combine_xyz_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Float>("X").min(-10000.0f).max(10000.0f);
|
||||
b.add_input<decl::Float>("Y").min(-10000.0f).max(10000.0f);
|
||||
b.add_input<decl::Float>("Z").min(-10000.0f).max(10000.0f);
|
||||
b.add_output<decl::Vector>("Vector");
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_cmp_combine_xyz()
|
||||
{
|
||||
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;
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
Reference in New Issue
Block a user