Blender V4.5
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
8
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::compositor;
36
38 public:
40
41 void execute() override
42 {
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_single_value_default(float3(0.0f)),
62 get_input("Scale").get_single_value_default(float3(1.0f)));
63
64 Result &color_result = get_result("Color");
65 if (color_result.should_compute()) {
66 color_result.wrap_external(cached_texture.color_result);
67 }
68
69 Result &value_result = get_result("Value");
70 if (value_result.should_compute()) {
71 value_result.wrap_external(cached_texture.value_result);
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, "CompositorNodeTexture", CMP_NODE_TEXTURE);
113 ntype.ui_name = "Texture";
114 ntype.ui_description = "Generate texture pattern from texture datablock";
115 ntype.enum_name_legacy = "TEXTURE";
116 ntype.nclass = NODE_CLASS_INPUT;
117 ntype.declare = file_ns::cmp_node_texture_declare;
119 "Texture nodes not supported in the Viewport compositor");
120 ntype.flag |= NODE_PREVIEW;
121 ntype.get_compositor_operation = file_ns::get_compositor_operation;
122
124}
#define NODE_CLASS_INPUT
Definition BKE_node.hh:433
#define CMP_NODE_TEXTURE
@ NODE_PREVIEW
#define NOD_REGISTER_NODE(REGISTER_FUNC)
@ PROP_XYZ
Definition RNA_types.hh:257
@ PROP_TRANSLATION
Definition RNA_types.hh:249
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_result(StringRef identifier)
Definition operation.cc:39
Result & get_input(StringRef identifier) const
Definition operation.cc:138
void wrap_external(GPUTexture *texture)
Definition result.cc:448
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
void node_register_type(bNodeType &ntype)
Definition node.cc:2748
static void cmp_node_texture_declare(NodeDeclarationBuilder &b)
static NodeOperation * get_compositor_operation(Context &context, DNode node)
VecBase< float, 3 > float3
static void register_node_type_cmp_texture()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
#define min(a, b)
Definition sort.cc:36
struct ID * id
Defines a node type.
Definition BKE_node.hh:226
std::string ui_description
Definition BKE_node.hh:232
NodeGetCompositorOperationFunction get_compositor_operation
Definition BKE_node.hh:336
const char * compositor_unsupported_message
Definition BKE_node.hh:341
const char * enum_name_legacy
Definition BKE_node.hh:235
NodeDeclareFunction declare
Definition BKE_node.hh:355
#define N_(msgid)