Blender V4.3
node_composite_texture.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2006 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include "COM_node_operation.hh"
11
13
14/* **************** TEXTURE ******************** */
15
17
19{
20 b.add_input<decl::Vector>("Offset")
21 .min(-2.0f)
22 .max(2.0f)
24 .compositor_expects_single_value();
25 b.add_input<decl::Vector>("Scale")
26 .default_value({1.0f, 1.0f, 1.0f})
27 .min(-10.0f)
28 .max(10.0f)
30 .compositor_expects_single_value();
31 b.add_output<decl::Float>("Value");
32 b.add_output<decl::Color>("Color");
33}
34
35using namespace blender::realtime_compositor;
36
38 public:
40
41 void execute() override
42 {
43 Tex *texture = get_texture();
44 if (!texture || !context().is_valid_compositing_region()) {
46 return;
47 }
48
49 if (texture->use_nodes) {
51 context().set_info_message("Viewport compositor setup not fully supported");
52 return;
53 }
54
55 const Domain domain = compute_domain();
57 context(),
58 texture,
59 true,
60 domain.size,
61 get_input("Offset").get_vector_value_default(float4(0.0f)).xyz(),
62 get_input("Scale").get_vector_value_default(float4(1.0f)).xyz());
63
64 Result &color_result = get_result("Color");
65 if (color_result.should_compute()) {
66 color_result.wrap_external(cached_texture.color_texture());
67 }
68
69 Result &value_result = get_result("Value");
70 if (value_result.should_compute()) {
71 value_result.wrap_external(cached_texture.value_texture());
72 }
73 }
74
76 {
77 Result &color_result = get_result("Color");
78 if (color_result.should_compute()) {
79 color_result.allocate_invalid();
80 }
81
82 Result &value_result = get_result("Value");
83 if (value_result.should_compute()) {
84 value_result.allocate_invalid();
85 }
86 }
87
89 {
90 return Domain(context().get_compositing_region_size());
91 }
92
94 {
95 return reinterpret_cast<Tex *>(bnode().id);
96 }
97};
98
100{
101 return new TextureOperation(context, node);
102}
103
104} // namespace blender::nodes::node_composite_texture_cc
105
107{
109
110 static blender::bke::bNodeType ntype;
111
112 cmp_node_type_base(&ntype, CMP_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT);
113 ntype.declare = file_ns::cmp_node_texture_declare;
115 "Texture nodes not supported in the Viewport compositor");
116 ntype.flag |= NODE_PREVIEW;
117 ntype.get_compositor_operation = file_ns::get_compositor_operation;
118
120}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:404
@ NODE_PREVIEW
@ PROP_XYZ
Definition RNA_types.hh:172
@ PROP_TRANSLATION
Definition RNA_types.hh:164
CachedTexture & get(Context &context, Tex *texture, bool use_color_management, int2 size, float3 offset, float3 scale)
virtual void set_info_message(StringRef message) const =0
NodeOperation(Context &context, DNode node)
Result & get_input(StringRef identifier) const
Definition operation.cc:144
Result & get_result(StringRef identifier)
Definition operation.cc:46
void wrap_external(GPUTexture *texture)
Definition result.cc:321
local_group_size(16, 16) .push_constant(Type b
void node_register_type(bNodeType *ntype)
Definition node.cc:1708
static void cmp_node_texture_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< float, 4 > float4
void register_node_type_cmp_texture()
void cmp_node_type_base(blender::bke::bNodeType *ntype, int type, const char *name, short nclass)
#define min(a, b)
Definition sort.c:32
struct ID * id
Defines a node type.
Definition BKE_node.hh:218
const char * realtime_compositor_unsupported_message
Definition BKE_node.hh:333
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:324
NodeDeclareFunction declare
Definition BKE_node.hh:347
#define N_(msgid)