forked from bartvdbraak/blender
Compositor: Add Scene Time Node, Rename Time node
Fixes issue T94603 It adds a new compositor node called Scene Time which is already present as a geo node, having the same basic nodes available in all node trees is a nice thing to have. Renames "Time" node to "Time Curve", this is done to avoid confusion between the Time node and the Scene Time node. Reviewed By: jbakker Maniphest Tasks: T94603 Differential Revision: https://developer.blender.org/D13762
This commit is contained in:
parent
a2c1c368af
commit
b2ccd8546c
@ -501,6 +501,7 @@ compositor_node_categories = [
|
||||
NodeItem("CompositorNodeTexture"),
|
||||
NodeItem("CompositorNodeBokehImage"),
|
||||
NodeItem("CompositorNodeTime"),
|
||||
NodeItem("CompositorNodeSceneTime"),
|
||||
NodeItem("CompositorNodeTrackPos"),
|
||||
]),
|
||||
CompositorNodeCategory("CMP_OUTPUT", "Output", items=[
|
||||
|
@ -1313,6 +1313,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *localtree,
|
||||
#define CMP_NODE_CRYPTOMATTE 326
|
||||
#define CMP_NODE_POSTERIZE 327
|
||||
#define CMP_NODE_CONVERT_COLOR_SPACE 328
|
||||
#define CMP_NODE_SCENE_TIME 329
|
||||
|
||||
/* channel toggles */
|
||||
#define CMP_CHAN_RGB 1
|
||||
|
@ -4447,6 +4447,7 @@ static void registerCompositNodes()
|
||||
register_node_type_cmp_value();
|
||||
register_node_type_cmp_rgb();
|
||||
register_node_type_cmp_curve_time();
|
||||
register_node_type_cmp_scene_time();
|
||||
register_node_type_cmp_movieclip();
|
||||
|
||||
register_node_type_cmp_composite();
|
||||
|
@ -147,6 +147,8 @@ set(SRC
|
||||
nodes/COM_TimeNode.h
|
||||
nodes/COM_ValueNode.cc
|
||||
nodes/COM_ValueNode.h
|
||||
nodes/COM_SceneTimeNode.cc
|
||||
nodes/COM_SceneTimeNode.h
|
||||
|
||||
# output nodes
|
||||
nodes/COM_CompositorNode.cc
|
||||
|
@ -94,6 +94,7 @@
|
||||
#include "COM_RotateNode.h"
|
||||
#include "COM_ScaleNode.h"
|
||||
#include "COM_ScaleOperation.h"
|
||||
#include "COM_SceneTimeNode.h"
|
||||
#include "COM_SeparateColorNode.h"
|
||||
#include "COM_SetAlphaNode.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
@ -360,6 +361,9 @@ Node *COM_convert_bnode(bNode *b_node)
|
||||
case CMP_NODE_TRANSFORM:
|
||||
node = new TransformNode(b_node);
|
||||
break;
|
||||
case CMP_NODE_SCENE_TIME:
|
||||
node = new SceneTimeNode(b_node);
|
||||
break;
|
||||
case CMP_NODE_STABILIZE2D:
|
||||
node = new Stabilize2dNode(b_node);
|
||||
break;
|
||||
|
50
source/blender/compositor/nodes/COM_SceneTimeNode.cc
Normal file
50
source/blender/compositor/nodes/COM_SceneTimeNode.cc
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 2022, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include "COM_SceneTimeNode.h"
|
||||
|
||||
#include "COM_SetValueOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
SceneTimeNode::SceneTimeNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void SceneTimeNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
SetValueOperation *SecondOperation = new SetValueOperation();
|
||||
SetValueOperation *frameOperation = new SetValueOperation();
|
||||
|
||||
const int frameNumber = context.get_framenumber();
|
||||
const Scene* scene = context.get_scene();
|
||||
const double frameRate = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
|
||||
|
||||
SecondOperation->set_value(float(frameNumber / frameRate));
|
||||
converter.add_operation(SecondOperation);
|
||||
|
||||
frameOperation->set_value(frameNumber);
|
||||
converter.add_operation(frameOperation);
|
||||
|
||||
converter.map_output_socket(get_output_socket(0), SecondOperation->get_output_socket());
|
||||
converter.map_output_socket(get_output_socket(1), frameOperation->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
36
source/blender/compositor/nodes/COM_SceneTimeNode.h
Normal file
36
source/blender/compositor/nodes/COM_SceneTimeNode.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 2022, Blender Foundation.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_Node.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
/**
|
||||
* \brief SceneTimeNode
|
||||
* \ingroup Node
|
||||
*/
|
||||
class SceneTimeNode : public Node {
|
||||
public:
|
||||
SceneTimeNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
@ -185,6 +185,7 @@ extern StructRNA RNA_CompositorNodeRGBToBW;
|
||||
extern StructRNA RNA_CompositorNodeRLayers;
|
||||
extern StructRNA RNA_CompositorNodeRotate;
|
||||
extern StructRNA RNA_CompositorNodeScale;
|
||||
extern StructRNA RNA_CompositorNodeSceneTime;
|
||||
extern StructRNA RNA_CompositorNodeSepHSVA;
|
||||
extern StructRNA RNA_CompositorNodeSepRGBA;
|
||||
extern StructRNA RNA_CompositorNodeSepYCCA;
|
||||
|
@ -43,6 +43,7 @@ void register_node_type_cmp_texture(void);
|
||||
void register_node_type_cmp_value(void);
|
||||
void register_node_type_cmp_rgb(void);
|
||||
void register_node_type_cmp_curve_time(void);
|
||||
void register_node_type_cmp_scene_time(void);
|
||||
void register_node_type_cmp_movieclip(void);
|
||||
|
||||
void register_node_type_cmp_composite(void);
|
||||
|
@ -148,7 +148,7 @@ DefNode(CompositorNode, CMP_NODE_BLUR, def_cmp_blur, "BLUR",
|
||||
DefNode(CompositorNode, CMP_NODE_FILTER, def_cmp_filter, "FILTER", Filter, "Filter", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_MAP_VALUE, def_cmp_map_value, "MAP_VALUE", MapValue, "Map Value", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_MAP_RANGE, def_cmp_map_range, "MAP_RANGE", MapRange, "Map Range", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_TIME, def_time, "TIME", Time, "Time Curve", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_VECBLUR, def_cmp_vector_blur, "VECBLUR", VecBlur, "Vector Blur", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" )
|
||||
DefNode(CompositorNode, CMP_NODE_SEPHSVA, 0, "SEPHSVA", SepHSVA, "Separate HSVA", "" )
|
||||
@ -228,6 +228,7 @@ DefNode(CompositorNode, CMP_NODE_EXPOSURE, 0, "EXPOSU
|
||||
DefNode(CompositorNode, CMP_NODE_ANTIALIASING, def_cmp_antialiasing, "ANTIALIASING", AntiAliasing, "Anti-Aliasing", "" )
|
||||
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(TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
|
||||
DefNode(TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
|
||||
|
@ -122,6 +122,7 @@ set(SRC
|
||||
nodes/node_composite_vec_blur.cc
|
||||
nodes/node_composite_viewer.cc
|
||||
nodes/node_composite_zcombine.cc
|
||||
nodes/node_composite_scene_time.cc
|
||||
|
||||
node_composite_tree.cc
|
||||
node_composite_util.cc
|
||||
|
@ -51,7 +51,7 @@ void register_node_type_cmp_curve_time()
|
||||
|
||||
static bNodeType ntype;
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time", NODE_CLASS_INPUT);
|
||||
cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time Curve", NODE_CLASS_INPUT);
|
||||
ntype.declare = file_ns::cmp_node_time_declare;
|
||||
node_type_size(&ntype, 200, 140, 320);
|
||||
node_type_init(&ntype, file_ns::node_composit_init_curves_time);
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
/** \file
|
||||
* \ingroup cmpnodes
|
||||
*/
|
||||
|
||||
#include "node_composite_util.hh"
|
||||
|
||||
namespace blender::nodes {
|
||||
|
||||
static void cmp_node_scene_time_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Float>(N_("Seconds"));
|
||||
b.add_output<decl::Float>(N_("Frame"));
|
||||
}
|
||||
|
||||
} // namespace blender::nodes
|
||||
|
||||
void register_node_type_cmp_scene_time()
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_SCENE_TIME, "Scene Time", NODE_CLASS_INPUT);
|
||||
ntype.declare = blender::nodes::cmp_node_scene_time_declare;
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
Loading…
Reference in New Issue
Block a user